Selfie
Loading...
Searching...
No Matches
pytest_selfie.plugin Namespace Reference

Classes

class  _keydefaultdict
 
class  DiskStoragePytest
 
class  FSImplementation
 
class  PytestSnapshotFileLayout
 
class  PytestSnapshotSystem
 
class  SnapshotFileProgress
 

Functions

None pytest_collection_modifyitems (pytest.Session session, pytest.Config config, list[pytest.Item] items)
 
 pytest_sessionfinish (pytest.Session session, exitstatus)
 
 pytest_runtest_protocol (pytest.Item item, Optional[pytest.Item] nextitem)
 
 pytest_runtest_makereport (pytest.CallInfo[None] call, pytest.Item item)
 
 delete_file_and_parent_dir_if_empty (TypedPath snapshot_file)
 
ArrayMap[str, WithinTestGCfind_test_methods_that_didnt_run (TypedPath testfile, ArrayMap[str, WithinTestGC] tests)
 
 pytest_addoption (parser)
 
 bar (request)
 

Function Documentation

◆ bar()

pytest_selfie.plugin.bar (   request)

Definition at line 479 of file plugin.py.

479def bar(request):
480 return request.config.option.dest_foo

◆ delete_file_and_parent_dir_if_empty()

pytest_selfie.plugin.delete_file_and_parent_dir_if_empty ( TypedPath  snapshot_file)

Definition at line 447 of file plugin.py.

447def delete_file_and_parent_dir_if_empty(snapshot_file: TypedPath):
448 if os.path.isfile(snapshot_file.absolute_path):
449 os.remove(snapshot_file.absolute_path)
450 # if the parent folder is now empty, delete it
451 parent = os.path.dirname(snapshot_file.absolute_path)
452 if not os.listdir(parent):
453 os.rmdir(parent)
454
455

◆ find_test_methods_that_didnt_run()

ArrayMap[str, WithinTestGC] pytest_selfie.plugin.find_test_methods_that_didnt_run ( TypedPath  testfile,
ArrayMap[str, WithinTestGC tests 
)

Definition at line 456 of file plugin.py.

459) -> ArrayMap[str, WithinTestGC]:
460 # Implementation of finding test methods that didn't run
461 # You can replace this with your own logic based on the class_name and tests dictionary
462 return ArrayMap.empty()
463
464

◆ pytest_addoption()

pytest_selfie.plugin.pytest_addoption (   parser)

Definition at line 465 of file plugin.py.

465def pytest_addoption(parser):
466 group = parser.getgroup("selfie")
467 group.addoption(
468 "--foo",
469 action="store",
470 dest="dest_foo",
471 default="2024",
472 help='Set the value for the fixture "bar".',
473 )
474
475 parser.addini("HELLO", "Dummy pytest.ini setting")
476
477
478@pytest.fixture

◆ pytest_collection_modifyitems()

None pytest_selfie.plugin.pytest_collection_modifyitems ( pytest.Session  session,
pytest.Config  config,
list[pytest.Item]   items 
)

Definition at line 98 of file plugin.py.

100) -> None:
101 settings = SelfieSettingsAPI(config)
102 system = PytestSnapshotSystem(settings)
103 session.selfie_system = system # type: ignore
104 _initSelfieSystem(system)
105 for item in items:
106 (file, _, testname) = item.reportinfo()
107 system.planning_to_run(TypedPath.of_file(os.path.abspath(file)), testname)
108
109
110@pytest.hookimpl

◆ pytest_runtest_makereport()

pytest_selfie.plugin.pytest_runtest_makereport ( pytest.CallInfo[None]  call,
pytest.Item  item 
)

Definition at line 129 of file plugin.py.

129def pytest_runtest_makereport(call: pytest.CallInfo[None], item: pytest.Item):
130 if call.excinfo is not None and call.when in (
131 "call",
132 "teardown",
133 ):
134 system: PytestSnapshotSystem = item.session.selfie_system # type: ignore
135 (file, _, testname) = item.reportinfo()
136 system.test_failed(TypedPath.of_file(os.path.abspath(file)), testname)
137
138

◆ pytest_runtest_protocol()

pytest_selfie.plugin.pytest_runtest_protocol ( pytest.Item  item,
Optional[pytest.Item]  nextitem 
)

Definition at line 118 of file plugin.py.

118def pytest_runtest_protocol(item: pytest.Item, nextitem: Optional[pytest.Item]): # noqa: ARG001
119 (file, _, testname) = item.reportinfo()
120 testfile = TypedPath.of_file(os.path.abspath(file))
121
122 system: PytestSnapshotSystem = item.session.selfie_system # type: ignore
123 system.test_start(testfile, testname)
124 yield
125 system.test_finish(testfile, testname)
126
127
128@pytest.hookimpl

◆ pytest_sessionfinish()

pytest_selfie.plugin.pytest_sessionfinish ( pytest.Session  session,
  exitstatus 
)

Definition at line 111 of file plugin.py.

111def pytest_sessionfinish(session: pytest.Session, exitstatus): # noqa: ARG001
112 system: PytestSnapshotSystem = session.selfie_system # type: ignore
113 system.finished_all_tests()
114 _clearSelfieSystem(system)
115
116
117@pytest.hookimpl(hookwrapper=True)