86 lines
2.9 KiB
Diff
86 lines
2.9 KiB
Diff
diff -Nur pytest-mock-1.10.0/test_pytest_mock.py pytest-mock-1.10.0_bak/test_pytest_mock.py
|
|
--- pytest-mock-1.10.0/test_pytest_mock.py 2018-05-02 01:10:54.000000000 +0800
|
|
+++ pytest-mock-1.10.0_bak/test_pytest_mock.py 2021-06-03 16:34:18.277654058 +0800
|
|
@@ -12,6 +12,9 @@
|
|
skip_pypy = pytest.mark.skipif(platform.python_implementation() == 'PyPy',
|
|
reason='could not make work on pypy')
|
|
|
|
+#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
|
|
def needs_assert_rewrite(pytestconfig):
|
|
@@ -179,7 +182,11 @@
|
|
|
|
def __test_failure_message(self, mocker, **kwargs):
|
|
expected_name = kwargs.get('name') or 'mock'
|
|
- expected_message = 'Expected call: {0}()\nNot called'.format(expected_name)
|
|
+ if NEW_FORMATTING:
|
|
+ msg = "expected call not found.\nExpected: {0}()\nActual: not called."
|
|
+ else:
|
|
+ msg = "Expected call: {0}()\nNot called"
|
|
+ expected_message = msg.format(expected_name)
|
|
stub = mocker.stub(**kwargs)
|
|
with pytest.raises(AssertionError) as exc_info:
|
|
stub.assert_called_with()
|
|
@@ -559,20 +566,30 @@
|
|
m.assert_called_once_with('', bar=4)
|
|
""")
|
|
result = testdir.runpytest('-s')
|
|
- result.stdout.fnmatch_lines([
|
|
- "*AssertionError: Expected call: mock('', bar=4)*",
|
|
- "*Actual call: mock('fo')*",
|
|
+ if NEW_FORMATTING:
|
|
+ expected_lines = [
|
|
+ "*AssertionError: expected call not found.",
|
|
+ "*Expected: mock('', bar=4)",
|
|
+ "*Actual: mock('fo')",
|
|
+ ]
|
|
+ else:
|
|
+ expected_lines = [
|
|
+ "*AssertionError: Expected call: mock('', bar=4)*",
|
|
+ "*Actual call: mock('fo')*",
|
|
+ ]
|
|
+ expected_lines += [
|
|
"*pytest introspection follows:*",
|
|
- '*Args:',
|
|
+ "*Args:",
|
|
"*assert ('fo',) == ('',)",
|
|
"*At index 0 diff: 'fo' != ''*",
|
|
"*Use -v to get the full diff*",
|
|
"*Kwargs:*",
|
|
"*assert {} == {'bar': 4}*",
|
|
- "*Right contains more items:*",
|
|
+ "*Right contains* more item*",
|
|
"*{'bar': 4}*",
|
|
"*Use -v to get the full diff*",
|
|
- ])
|
|
+ ]
|
|
+ result.stdout.fnmatch_lines(expected_lines)
|
|
|
|
|
|
def test_assert_called_with_unicode_arguments(mocker):
|
|
diff -Nur pytest-mock-1.10.0/tox.ini pytest-mock-1.10.0_bak/tox.ini
|
|
--- pytest-mock-1.10.0/tox.ini 2018-05-02 01:10:54.000000000 +0800
|
|
+++ pytest-mock-1.10.0_bak/tox.ini 2021-06-03 15:57:02.000000000 +0800
|
|
@@ -12,7 +12,7 @@
|
|
|
|
[testenv:norewrite]
|
|
commands =
|
|
- pytest test_pytest_mock.py --assert=plain -ra
|
|
+ pytest test_pytest_mock.py --assert=plain
|
|
|
|
[testenv:linting]
|
|
skip_install=True
|
|
@@ -23,3 +23,9 @@
|
|
commands =
|
|
py.test --flakes pytest_mock.py test_pytest_mock.py -m flakes
|
|
rst-lint CHANGELOG.rst README.rst
|
|
+
|
|
+[tool:pytest]
|
|
+addopts = -r a
|
|
+
|
|
+[flake8]
|
|
+max-line-length = 88
|