coincidence.selectors

Pytest decorators for selectively running tests.

Functions:

min_version(version[, reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version is less than the required one.

max_version(version[, reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version is greater than the required one.

only_version(version[, reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version not the required one.

not_windows([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is Windows.

only_windows([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is Windows.

not_pypy([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python implementation is PyPy.

only_pypy([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current Python implementation is PyPy.

not_macos([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is macOS.

only_macos([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is macOS.

not_docker([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if running on Docker.

not_linux([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is Linux.

only_linux([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is Linux.

only_docker([reason])

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless running on Docker.

platform_boolean_factory(condition, platform)

Factory function to return decorators such as not_pypy() and only_windows().

min_version(version, reason=None)[source]

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version is less than the required one.

Parameters
Return type

MarkDecorator

max_version(version, reason=None)[source]

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version is greater than the required one.

Parameters
Return type

MarkDecorator

only_version(version, reason=None)[source]

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python version not the required one.

Parameters
Return type

MarkDecorator

not_windows(reason='Not required on Windows')

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is Windows.

Parameters

reason (str) – The reason to display when skipping. Default 'Not required on Windows'.

Return type

MarkDecorator

only_windows(reason='Only required on Windows')

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is Windows.

Parameters

reason (str) – The reason to display when skipping. Default 'Only required on Windows'.

Return type

MarkDecorator

not_pypy(reason='Not required on PyPy')

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current Python implementation is PyPy.

Parameters

reason (str) – The reason to display when skipping. Default 'Not required on PyPy'.

Return type

MarkDecorator

only_pypy(reason='Only required on PyPy')

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current Python implementation is PyPy.

Parameters

reason (str) – The reason to display when skipping. Default 'Only required on PyPy'.

Return type

MarkDecorator

not_macos(reason='Not required on macOS')

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is macOS.

Parameters

reason (str) – The reason to display when skipping. Default 'Not required on macOS'.

Return type

MarkDecorator

only_macos(reason='Only required on macOS')

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is macOS.

Parameters

reason (str) – The reason to display when skipping. Default 'Only required on macOS'.

Return type

MarkDecorator

not_docker(reason='Not required on Docker')

Factory function to return a @pytest.mark.skipif decorator which will skip a test if running on Docker.

Parameters

reason (str) – The reason to display when skipping. Default 'Not required on Docker'.

Return type

MarkDecorator

not_linux(reason='Not required on Linux')

Factory function to return a @pytest.mark.skipif decorator which will skip a test if the current platform is Linux.

New in version 0.2.0.

Parameters

reason (str) – The reason to display when skipping. Default 'Not required on Linux'.

Return type

MarkDecorator

only_linux(reason='Only required on Linux')

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless the current platform is Linux.

New in version 0.2.0.

Parameters

reason (str) – The reason to display when skipping. Default 'Only required on Linux'.

Return type

MarkDecorator

only_docker(reason='Only required on Docker')

Factory function to return a @pytest.mark.skipif decorator which will skip a test unless running on Docker.

Parameters

reason (str) – The reason to display when skipping. Default 'Only required on Docker'.

Return type

MarkDecorator

platform_boolean_factory(condition, platform, versionadded=None, *, module=None)[source]

Factory function to return decorators such as not_pypy() and only_windows().

Parameters
  • condition (bool) – Should evaluate to True if the test should be skipped.

  • platform (str)

  • versionadded (Optional[str]) – Default None.

  • module (Optional[str]) – The module to set the function as belonging to in __module__. If None __module__ is set to 'coincidence.selectors'. Default None.

Return type

Tuple[Callable[…, MarkDecorator], Callable[…, MarkDecorator]]

Returns

2-element tuple of not_function, only_function.