def output_fixtures( fixtures: List[Fixture], tests: List[Test], show_scopes: bool, show_docstrings: bool, show_dependencies: bool, show_dependency_trees: bool, ): generated_tests = itertools.chain.from_iterable( test.get_parameterised_instances() for test in tests ) fixture_to_tests = fixtures_used_directly_by_tests(generated_tests) fixtures_to_parents, fixtures_to_children = fixture_parents_and_children(fixtures) for module, fixtures in group_by(fixtures, key=lambda f: f.module_name).items(): rich_console.print(Rule(Text(module, style="title"))) for fixture in fixtures: fixture_tree = make_fixture_information_tree( fixture, used_by_tests=fixture_to_tests[fixture], fixtures_to_children=fixtures_to_children, fixtures_to_parents=fixtures_to_parents, show_scopes=show_scopes, show_docstrings=show_docstrings, show_dependencies=show_dependencies, show_dependency_trees=show_dependency_trees, ) rich_console.print(fixture_tree)
def _(): @fixture def a(): pass @fixture def b(): pass @fixture def c(a=a, b=b): pass @fixture def d(a=a, c=c): pass fa, fb, fc, fd = fixtures = [Fixture(f) for f in (a, b, c, d)] to_parents, to_children = fixture_parents_and_children(fixtures) assert to_parents == {fa: [], fb: [], fc: [fa, fb], fd: [fa, fc]} assert to_children == { fa: [fc, fd], fb: [fc], fc: [fd], fd: [], }