Skip to content

Commit

Permalink
Fix tests due to new formatting in mock 3.0 and python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed May 3, 2019
1 parent 3bb4d0a commit b2683fd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test_pytest_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

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

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


@pytest.fixture
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_repr_with_name(self, mocker):

def __test_failure_message(self, mocker, **kwargs):
expected_name = kwargs.get("name") or "mock"
if PY38:
if NEW_FORMATTING:
msg = "expected call not found.\nExpected: {0}()\nActual: not called."
else:
msg = "Expected call: {0}()\nNot called"
Expand Down Expand Up @@ -620,7 +620,7 @@ def test(mocker):
"""
)
result = testdir.runpytest("-s")
if PY38:
if NEW_FORMATTING:
expected_lines = [
"*AssertionError: expected call not found.",
"*Expected: mock('', bar=4)",
Expand Down

0 comments on commit b2683fd

Please sign in to comment.