Skip to content

Commit b3badaf

Browse files
authored
Fix tests due to new formatting in mock 3.0 and python 3.8 (#145)
Fix tests due to new formatting in mock 3.0 and python 3.8
2 parents 3bb4d0a + b2683fd commit b3badaf

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test_pytest_mock.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
# could not make some of the tests work on PyPy, patches are welcome!
1212
skip_pypy = pytest.mark.skipif(
13-
platform.python_implementation() == "PyPy", reason="could not make work on pypy"
13+
platform.python_implementation() == "PyPy", reason="could not make it work on pypy"
1414
)
1515

16-
# Python 3.8 changed the output formatting (bpo-35500).
17-
PY38 = sys.version_info >= (3, 8)
16+
# Python 3.8 changed the output formatting (bpo-35500), which has been ported to mock 3.0
17+
NEW_FORMATTING = sys.version_info >= (3, 8) or sys.version_info[0] == 2
1818

1919

2020
@pytest.fixture
@@ -209,7 +209,7 @@ def test_repr_with_name(self, mocker):
209209

210210
def __test_failure_message(self, mocker, **kwargs):
211211
expected_name = kwargs.get("name") or "mock"
212-
if PY38:
212+
if NEW_FORMATTING:
213213
msg = "expected call not found.\nExpected: {0}()\nActual: not called."
214214
else:
215215
msg = "Expected call: {0}()\nNot called"
@@ -620,7 +620,7 @@ def test(mocker):
620620
"""
621621
)
622622
result = testdir.runpytest("-s")
623-
if PY38:
623+
if NEW_FORMATTING:
624624
expected_lines = [
625625
"*AssertionError: expected call not found.",
626626
"*Expected: mock('', bar=4)",

0 commit comments

Comments
 (0)