userver: pytest_userver.plugins.generated_tests Namespace Reference
Loading...
Searching...
No Matches
pytest_userver.plugins.generated_tests Namespace Reference

Detailed Description

Pytest infrastructure plugin for collecting virtual generated tests.

The plugin adds a synthetic file named __test_generated__.py under the first collection directory from config.args and exposes a custom pytest hook, pytest_generate_virtual_tests.

Other plugins can implement that hook to return generated pytest.Item objects, usually pytest.Function items.

Generated tests are not backed by a real Python file, but they get a normal pytest parent chain and can use pytest fixtures when implemented as pytest.Function objects.

Classes

class  _FakeModule
 
class  _GeneratedTestsDir
 
class  _GeneratedTestsDirectoryMixin
 
class  _GeneratedTestsFile
 
class  _GeneratedTestsPackage
 
class  GeneratedTestsPluginHooks
 Custom pytest (pluggy) hooks customizing generated tests. More...
 

Functions

None pytest_addhooks (pytest.PytestPluginManager pluginmanager)
 
None pytest_configure (pytest.Config config)
 
None pytest_itemcollected (pytest.Item item)
 
pathlib.Path|None _get_first_collection_directory (pytest.Config config)
 
 pytest_collect_directory (pathlib.Path path, pytest.Collector parent)
 
pytest.Directory _create_wrapped_directory (*, pytest.Collector parent, pathlib.Path path)
 

Variables

bool _IS_ARCADIA = True
 
str _GENERATED_FILENAME = '__test_generated__.py'
 
 _GENERATED_TESTS_DIR_KEY = pytest.StashKey[pathlib.Path | None]()
 
 _COLLECTED_ITEMS_KEY = pytest.StashKey[list[pytest.Item]]()
 

Function Documentation

◆ _create_wrapped_directory()

pytest.Directory pytest_userver.plugins.generated_tests._create_wrapped_directory ( * ,
pytest.Collector parent,
pathlib.Path path )
protected

Definition at line 117 of file generated_tests.py.

◆ _get_first_collection_directory()

pathlib.Path | None pytest_userver.plugins.generated_tests._get_first_collection_directory ( pytest.Config config)
protected

Definition at line 79 of file generated_tests.py.

◆ pytest_addhooks()

None pytest_userver.plugins.generated_tests.pytest_addhooks ( pytest.PytestPluginManager pluginmanager)

Definition at line 56 of file generated_tests.py.

◆ pytest_collect_directory()

pytest_userver.plugins.generated_tests.pytest_collect_directory ( pathlib.Path path,
pytest.Collector parent )

Definition at line 102 of file generated_tests.py.

◆ pytest_configure()

None pytest_userver.plugins.generated_tests.pytest_configure ( pytest.Config config)

Definition at line 60 of file generated_tests.py.

◆ pytest_itemcollected()

None pytest_userver.plugins.generated_tests.pytest_itemcollected ( pytest.Item item)

Definition at line 69 of file generated_tests.py.

Variable Documentation

◆ _COLLECTED_ITEMS_KEY

pytest_userver.plugins.generated_tests._COLLECTED_ITEMS_KEY = pytest.StashKey[list[pytest.Item]]()
protected

Definition at line 33 of file generated_tests.py.

◆ _GENERATED_FILENAME

str pytest_userver.plugins.generated_tests._GENERATED_FILENAME = '__test_generated__.py'
protected

Definition at line 30 of file generated_tests.py.

◆ _GENERATED_TESTS_DIR_KEY

pytest_userver.plugins.generated_tests._GENERATED_TESTS_DIR_KEY = pytest.StashKey[pathlib.Path | None]()
protected

Definition at line 32 of file generated_tests.py.

◆ _IS_ARCADIA

bool pytest_userver.plugins.generated_tests._IS_ARCADIA = True
protected

Definition at line 26 of file generated_tests.py.