diff options
author | Susan Su <susansu.software@gmail.com> | 2019-02-14 02:22:29 (GMT) |
---|---|---|
committer | Lisa Roach <lisaroach14@gmail.com> | 2019-02-14 02:22:29 (GMT) |
commit | 2bdd5858e3f89555c8de73a0f307d63536129dbd (patch) | |
tree | 244b0cf7117ac457358e249db39516814801d787 /Lib/unittest/test | |
parent | 1dc5cb9cb3447211069a7788208254b1cfa8ec98 (diff) | |
download | cpython-2bdd5858e3f89555c8de73a0f307d63536129dbd.zip cpython-2bdd5858e3f89555c8de73a0f307d63536129dbd.tar.gz cpython-2bdd5858e3f89555c8de73a0f307d63536129dbd.tar.bz2 |
bpo-35500: align expected and actual calls on mock.assert_called_with error message. (GH-11804)
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 64e2fcf..04ab522 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -724,7 +724,7 @@ class MockTest(unittest.TestCase): def test_assert_called_with_message(self): mock = Mock() - self.assertRaisesRegex(AssertionError, 'Not called', + self.assertRaisesRegex(AssertionError, 'not called', mock.assert_called_with) @@ -917,10 +917,11 @@ class MockTest(unittest.TestCase): def test_assert_called_with_failure_message(self): mock = NonCallableMock() + actual = 'not called.' expected = "mock(1, '2', 3, bar='foo')" - message = 'Expected call: %s\nNot called' + message = 'expected call not found.\nExpected: %s\nActual: %s' self.assertRaisesWithMsg( - AssertionError, message % (expected,), + AssertionError, message % (expected, actual), mock.assert_called_with, 1, '2', 3, bar='foo' ) @@ -933,7 +934,7 @@ class MockTest(unittest.TestCase): for meth in asserters: actual = "foo(1, '2', 3, foo='foo')" expected = "foo(1, '2', 3, bar='foo')" - message = 'Expected call: %s\nActual call: %s' + message = 'expected call not found.\nExpected: %s\nActual: %s' self.assertRaisesWithMsg( AssertionError, message % (expected, actual), meth, 1, '2', 3, bar='foo' @@ -943,7 +944,7 @@ class MockTest(unittest.TestCase): for meth in asserters: actual = "foo(1, '2', 3, foo='foo')" expected = "foo(bar='foo')" - message = 'Expected call: %s\nActual call: %s' + message = 'expected call not found.\nExpected: %s\nActual: %s' self.assertRaisesWithMsg( AssertionError, message % (expected, actual), meth, bar='foo' @@ -953,7 +954,7 @@ class MockTest(unittest.TestCase): for meth in asserters: actual = "foo(1, '2', 3, foo='foo')" expected = "foo(1, 2, 3)" - message = 'Expected call: %s\nActual call: %s' + message = 'expected call not found.\nExpected: %s\nActual: %s' self.assertRaisesWithMsg( AssertionError, message % (expected, actual), meth, 1, 2, 3 @@ -963,7 +964,7 @@ class MockTest(unittest.TestCase): for meth in asserters: actual = "foo(1, '2', 3, foo='foo')" expected = "foo()" - message = 'Expected call: %s\nActual call: %s' + message = 'expected call not found.\nExpected: %s\nActual: %s' self.assertRaisesWithMsg( AssertionError, message % (expected, actual), meth ) |