diff --git a/.github/workflows/standard.yaml b/.github/workflows/standard.yaml index 043e976..9668dab 100644 --- a/.github/workflows/standard.yaml +++ b/.github/workflows/standard.yaml @@ -47,4 +47,4 @@ jobs: - name: Test with pytest run: | pip install pytest pytest-cov - pytest tests/test_generation.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -n auto + pytest tests/test_generation.py --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html --subset-percentage 0.1 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..4f880d7 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,27 @@ +import random + + +def pytest_addoption(parser): + parser.addoption( + "--subset-percentage", + action="store", + default=None, + help="Specify the percentage of tests to run as a subset (e.g., 0.3 for 30%)", + ) + + +def pytest_collection_modifyitems(config, items): + subset_percentage = config.getoption("--subset-percentage") + + # If the subset percentage is provided, apply it + if subset_percentage is not None: + subset_percentage = float(subset_percentage) + + # Shuffle the test cases + random.shuffle(items) + + # Calculate the number of tests to run based on percentage + subset_count = int(len(items) * subset_percentage) + + # Select a subset of tests + items[:] = items[:subset_count]