Skip to content

Tests are incorrectly split if paired with mark expressions #17

@matthewshirley

Description

@matthewshirley

Splitting tests when using pytest marker expressions is appearing to break the splitting. For example, I added this to a Django project that has a mixture of unit and functional tests. The functional tests are marked with @pytest.mark.browser while other test have different or no marks. There are 347 tests with the marker. This is how the collection preformed when I split only the browser tests:

pytest -m "browser" --splits 3 --group 1

[pytest-split] Running group 1/2
collected 5399 items / 5399 deselected                                                                                                                                 

pytest -m "browser" --splits 2 --group 2

[pytest-split] Running group 2/2
collected 5399 items / 5052 deselected / 347 selected

Steps to reproduce

See test case in #18. If you execute this code with tryfirst=True, one group will deselect all tests instead of splitting.

Proposal

See #18.

In summary, I think we should change pytest_collection_modifyitems to trylast=True instead of tryfirst=True to fix the aforementioned bug and performance issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions