forked from pool/python-pytest-profiling
39 lines
1.6 KiB
Diff
39 lines
1.6 KiB
Diff
|
|
From 5054ade74d72cdcc2096ecbde3355253894a43a0 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Steve Kowalik <steven@wedontsleep.org>
|
||
|
|
Date: Tue, 12 Mar 2024 15:12:00 +1100
|
||
|
|
Subject: [PATCH] pytest-profiling: Fix mock in test_writes_summary
|
||
|
|
|
||
|
|
In Python < 3.12, MagicMock's will blindly call any method provided to
|
||
|
|
them, which is masking a real issue in this testcase. The correct method
|
||
|
|
is assert_called_with(), and even worse, one of the arguments provided
|
||
|
|
isn't correct either. Correct the method call, and provide the correct
|
||
|
|
argument.
|
||
|
|
---
|
||
|
|
pytest-profiling/tests/unit/test_profile.py | 5 ++++-
|
||
|
|
1 file changed, 4 insertions(+), 1 deletion(-)
|
||
|
|
|
||
|
|
Index: pytest-profiling-1.7.0/tests/unit/test_profile.py
|
||
|
|
===================================================================
|
||
|
|
--- pytest-profiling-1.7.0.orig/tests/unit/test_profile.py
|
||
|
|
+++ pytest-profiling-1.7.0/tests/unit/test_profile.py
|
||
|
|
@@ -2,6 +2,7 @@
|
||
|
|
# the top-level code in pytest_profiling will be omitted from
|
||
|
|
# coverage, so force it to be reloaded within this test unit under coverage
|
||
|
|
|
||
|
|
+import os.path
|
||
|
|
from importlib import reload # @UnresolvedImport
|
||
|
|
|
||
|
|
import pytest_profiling
|
||
|
|
@@ -49,8 +50,10 @@ def test_writes_summary():
|
||
|
|
with patch('pstats.Stats', return_value=stats) as Stats:
|
||
|
|
plugin.pytest_sessionfinish(Mock(), Mock())
|
||
|
|
plugin.pytest_terminal_summary(terminalreporter)
|
||
|
|
+ combined = os.path.abspath(
|
||
|
|
+ os.path.join(os.path.curdir, "prof", "combined.prof"))
|
||
|
|
assert 'Profiling' in terminalreporter.write.call_args[0][0]
|
||
|
|
- assert Stats.called_with(stats, stream=terminalreporter)
|
||
|
|
+ Stats.assert_called_with(combined, stream=terminalreporter)
|
||
|
|
|
||
|
|
|
||
|
|
def test_writes_summary_svg():
|