Skip to content

Commit f909f7d

Browse files
jdmergify[bot]
andauthored
test(profiling): increase verbosity and assert debug data (#4174)
Sometimes test are flaky and it's hard to debug them when they are not reproducible. This increases the verbosity of reports for pytest so it prints more data when test fails. This also adds details about a flaky test in test_asyncio that failed at least once for unknown reason on Windows. Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 2d4c038 commit f909f7d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tests/profiling/collector/test_stack_asyncio.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ async def hello() -> None:
5151
t2_name = _asyncio._task_get_name(t2)
5252

5353
cpu_time_found = False
54-
for event in events[stack_event.StackSampleEvent]:
54+
stack_sample_events = events[stack_event.StackSampleEvent]
55+
for event in stack_sample_events:
5556

5657
wall_time_ns[event.task_name] += event.wall_time_ns
5758

@@ -87,7 +88,7 @@ async def hello() -> None:
8788

8889
if _asyncio_compat.PY38_AND_LATER:
8990
# We don't know the name of this task for Python < 3.8
90-
assert wall_time_ns["main"] > 0
91+
assert wall_time_ns["main"] > 0, (wall_time_ns, stack_sample_events)
9192

9293
assert wall_time_ns[t1_name] > 0
9394
assert wall_time_ns[t2_name] > 0

tox.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ passenv=
236236
commands =
237237
# run only essential tests related to the tracing client
238238
tracer: python -m pytest {posargs} tests/tracer
239-
py27-profile: python -m tests.profiling.run pytest --capture=no --verbose --benchmark-disable --ignore-glob="*asyncio*" {posargs} tests/profiling
239+
py27-profile: python -m tests.profiling.run pytest --capture=no --verbosity=2 --benchmark-disable --ignore-glob="*asyncio*" {posargs} tests/profiling
240240
# Coverage is excluded from profile because of an issue with Python 3.5.
241-
py3{5,6,7,8,9,10}-profile: python -m tests.profiling.run pytest --no-cov --capture=no --verbose --benchmark-disable {posargs} tests/profiling
241+
py3{5,6,7,8,9,10}-profile: python -m tests.profiling.run pytest --no-cov --capture=no --verbosity=2 --benchmark-disable {posargs} tests/profiling
242242
# run only the opentrace tests
243243
opentracer: python -m pytest {posargs} tests/opentracer/core
244244
opentracer_asyncio: python -m pytest {posargs} tests/opentracer/test_tracer_asyncio.py

0 commit comments

Comments
 (0)