{"id":2729,"library":"pytest-test-groups","title":"pytest-test-groups","description":"pytest-test-groups is a Pytest plugin (current version 1.2.1) designed to split a test run into equally sized groups, allowing users to execute a subset of their tests. This is particularly useful in Continuous Integration (CI) environments for parallelizing test execution. The library maintains an active development status with periodic releases to support newer Python and Pytest versions.","status":"active","version":"1.2.1","language":"en","source_language":"en","source_url":"https://github.com/mark-adams/pytest-test-groups","tags":["pytest","testing","plugins","CI","parallelization"],"install":[{"cmd":"pip install pytest-test-groups","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"This is a plugin for the pytest testing framework. Version 1.1.0 and later require a modern version of pytest (e.g., >=4.0).","package":"pytest"}],"imports":[{"note":"The functionality is integrated directly into the `pytest` command-line interface. There are no common Python symbols users need to import from `pytest_test_groups`.","symbol":"pytest-test-groups","correct":"This plugin primarily extends pytest via command-line arguments and hooks; direct Python imports by end-users are not typically needed for its core functionality."}],"quickstart":{"code":"# Save as test_example.py\nimport pytest\n\ndef test_alpha():\n    assert True\n\ndef test_beta():\n    assert True\n\ndef test_gamma():\n    assert True\n\ndef test_delta():\n    assert True\n\ndef test_epsilon():\n    assert True\n\n# To run group 1 of 2:\n# pytest --test-group-count=2 --test-group-id=1\n\n# To run group 2 of 2:\n# pytest --test-group-count=2 --test-group-id=2\n\n# To ensure consistent grouping across runs, especially with random selection:\n# pytest --test-group-count=2 --test-group-id=1 --test-group-random-seed=123","lang":"python","description":"Create a test file and run pytest with the `--test-group-count` and `--test-group-id` arguments to execute a specific subset of tests. Optionally, use `--test-group-random-seed` for reproducible random grouping."},"warnings":[{"fix":"Upgrade to Python 3.8+ and ensure Pytest is updated to a compatible version (e.g., `pytest>=4.0`). Consider pinning `pytest-test-groups<1.1.0` if unable to upgrade Python or Pytest.","message":"Version 1.1.0 dropped support for Python 2.x and bumped the minimum required version of Pytest. Users on older Python or Pytest versions should use an earlier `pytest-test-groups` release.","severity":"breaking","affected_versions":"<1.1.0"},{"fix":"Upgrade to a supported Python version (e.g., Python 3.10+ for current `pytest` releases) if you are using recent `pytest` versions.","message":"As a pytest plugin, `pytest-test-groups` inherits compatibility requirements from `pytest`. Major `pytest` releases (e.g., `pytest` 8.0.0 and 9.0.0) have dropped support for older Python versions (Python 3.8 in `pytest` 8, Python 3.9 in `pytest` 9). Ensure your Python environment is compatible with your installed `pytest` version.","severity":"breaking","affected_versions":"pytest>=8.0.0, pytest-test-groups versions compatible with affected pytest versions"},{"fix":"Understand that `pytest-test-groups` provides a mechanism for splitting all tests into arbitrary, equally-sized buckets for parallelization, not for semantic grouping. Use `pytest.mark` for semantic grouping.","message":"`pytest-test-groups` divides *all collected tests* into groups based on their execution order or file path. It does not use `pytest.mark` decorators for custom, named test groups. If you need to run specific logical groups of tests (e.g., 'sanity', 'regression'), consider using `pytest.mark` with `-m` flags instead of or in conjunction with `pytest-test-groups`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always provide the `--test-group-random-seed=<INTEGER>` argument when running tests in groups, particularly in CI, to ensure reproducible test grouping.","message":"When using randomized test grouping (which can be the default or explicitly enabled), not specifying a `--test-group-random-seed` can lead to inconsistent group assignments between different test runs. This can complicate debugging or CI retries where the same tests need to be run in the same group.","severity":"gotcha","affected_versions":"All versions (especially 1.0.2+ which introduced the seed option)"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}