Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Add feature to display which plugins have been discovered #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/test_terminal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from types import ModuleType
from typing import Union
from unittest.mock import Mock

Expand Down Expand Up @@ -88,6 +89,7 @@ def prelude():
python_impl="CPython",
python_version="4.2",
ward_version="1.0.0dev1",
list_of_plugins=[],
)


Expand All @@ -110,6 +112,14 @@ def _(prelude: SessionPrelude = prelude):
assert next(render_iter) == "Loaded config from [b]pyproject.toml[/b]."


@test("SessionPrelude displays list of plugins discovered when it is supplied")
def _(prelude: SessionPrelude = prelude):
prelude.list_of_plugins = [("ward", ModuleType("ward"))]
render_iter = prelude.__rich_console__(None, None)
next(render_iter)
assert next(render_iter) == "The list of plugins discovered: ['ward']"


@fixture
def timing_stats_panel():
return TestTimingStatsPanel(
Expand Down
1 change: 1 addition & 0 deletions ward/_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test(
num_tests_collected=suite.num_tests_with_parameterisation,
num_fixtures_collected=len(_DEFINED_FIXTURES),
config_path=config_path,
list_of_plugins=plugins.list_name_plugin(),
)
)
writer = TestResultWriter(
Expand Down
3 changes: 3 additions & 0 deletions ward/_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class SessionPrelude:
python_impl: str = field(default=platform.python_implementation())
python_version: str = field(default=platform.python_version())
ward_version: str = field(default=__version__)
list_of_plugins: Optional[List] = field(default_factory=list)

def __rich_console__(self, c: Console, co: ConsoleOptions) -> RenderResult:
yield Rule(
Expand All @@ -285,6 +286,8 @@ def __rich_console__(self, c: Console, co: ConsoleOptions) -> RenderResult:
style="title",
)
)
if self.list_of_plugins:
yield f"The list of plugins discovered: {[name for name, plugin in self.list_of_plugins]}"
if self.config_path:
try:
path: Union[Path, str] = self.config_path.relative_to(Path.cwd())
Expand Down