Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor pytest_pycollect_makeitems #421

Merged

Commits on Oct 4, 2022

  1. refactor: Extracted logic for marking tests in auto mode into pytest_…

    …collection_modifyitems.
    
    pytest_pycollect_makeitem currently calls `Collector._genfunctions`, in order to delegate further collection of test items to the current pytest collector. It does so only to add the asyncio mark to async tests after the items have been collected.
    
    Rather than relying on a call to the protected `Collector._genfunctions` method the marking logic was moved to the pytest_collection_modifyitems hook, which is called at the end of the collection phase. This change removes the call to protected functions and makes the code easier to understand.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 4, 2022
    Configuration menu
    Copy the full SHA
    3f18811 View commit details
    Browse the repository at this point in the history
  2. refactor: Hoist up check for asyncio mode before trying to modify fun…

    …ction items.
    
    pytest_collection_modifyitems has no effect when asyncio mode is not set to AUTO. Moving the mode check out of the loop prevents unnecessary work.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 4, 2022
    Configuration menu
    Copy the full SHA
    f25c5cc View commit details
    Browse the repository at this point in the history

Commits on Oct 8, 2022

  1. refactor: Renamed _set_explicit_asyncio_mark and _has_explicit_asynci…

    …o_mark to _make_asyncio_fixture_function and _is_asyncio_fixture_function, respectively.
    
    The new names reflect the purpose of the functions, instead of what they do. The new names also avoid confusion with pytest markers by not using "mark" in their names.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    7485d70 View commit details
    Browse the repository at this point in the history
  2. refactor: Removed obsolete elif clause.

    Legacy mode has been removed, so we don't need an elif to check if we're in AUTO mode.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    a0b9fd6 View commit details
    Browse the repository at this point in the history
  3. refactor: Renamed the "holder" argument to _preprocess_async_fixtures…

    … to "processed_fixturedefs" to better reflect the purpose of the variable.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    97d5e32 View commit details
    Browse the repository at this point in the history
  4. refactor: Simplified branching structure of _preprocess_async_fixtures.

    It is safe to call _make_asyncio_fixture_function without checking whether the fixture function has been converted to an asyncio fixture function, because each fixture is only processed once in the loop.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    d9cfe5c View commit details
    Browse the repository at this point in the history
  5. refactor: Simplified logic in _preprocess_async_fixtures.

    Merged two if-clauses both of which cause the current fixturedef to be skipped.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    e49a093 View commit details
    Browse the repository at this point in the history
  6. refactor: Extracted _inject_fixture_argnames from _preprocess_async_f…

    …ixtures in order to improve readability.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    f539b7e View commit details
    Browse the repository at this point in the history
  7. refactor: Extracted _synchronize_async_fixture from _preprocess_async…

    …_fixtures in order to improve readability.
    
    Signed-off-by: Michael Seifert <m.seifert@digitalernachschub.de>
    seifertm committed Oct 8, 2022
    Configuration menu
    Copy the full SHA
    0a30818 View commit details
    Browse the repository at this point in the history