Skip to content

Commit a36a644

Browse files
committed
display current test function name
1 parent a8aa11c commit a36a644

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pymatviz/utils/testing.py

+17-5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ def interactive_check(
2222
) -> bool | None:
2323
"""Ask a human to visually inspect a plot.
2424
25+
Note: `pytest` would capture output by default, and you would
26+
need to pass `-s` to release capture.
27+
28+
Todo:
29+
- scale figure size by display.
30+
- possible to automatically release `pytest` capture?
31+
2532
Args:
2633
plot (plt.Figure | plt.Axes): Plot to inspect.
2734
elem_to_check (str): Prompt for what element in the plot to check.
@@ -57,11 +64,16 @@ def interactive_check(
5764

5865
# Ask the user to check (treat KeyboardInterrupt as "yes")
5966
try:
60-
good_enough: bool = (
61-
input(f"Please check the {elem_to_check}. Is it looking good? (y/n): ")
62-
.strip()
63-
.lower()
64-
) == "y"
67+
current_test_name = os.environ.get("PYTEST_CURRENT_TEST", "").removesuffix(
68+
"(call)"
69+
)
70+
print( # noqa: T201 (print)
71+
f"\nCurrently checking: {current_test_name}"
72+
f"\nPlease check the '{elem_to_check}'. ",
73+
end="",
74+
)
75+
76+
good_enough: bool = input("Is it looking good? (y/n): ").strip().lower() == "y"
6577
except KeyboardInterrupt:
6678
good_enough = True
6779

0 commit comments

Comments
 (0)