[issue18993] There is an overshadowed and invalid test in testmock.py
Berker Peksag added the comment: This has been fixed in https://hg.python.org/cpython/rev/c8c11082bd0c. -- nosy: +berker.peksag resolution: - out of date stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Mark Lawrence added the comment: Can we have a formal review on the latest patch please. -- nosy: +BreamoreBoy type: enhancement - behavior versions: +Python 3.5 -Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Xavier de Gaye added the comment: The duplicate_code_names.py script in issue 16079 did find that there are duplicate test_attribute_deletion tests in testmock.py (see http://bugs.python.org/file27376/std_lib_duplicates.txt). -- nosy: +xdegaye ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Michael Foord added the comment: On balance I think that this test failing is *correct* (after deleting an attribute the old mock should *not* come back). I'd rather adjust the test to assert this than just remove it though. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Vajrasky Kok added the comment: Michael, attached the patch to accommodate your request. Yeah, I think this is the best way because I have seen no possible solutions to make both tests work without altering them. Xavier, that's cool. I didn't know such tool exists. Usually I found the duplicate function/method by using flake plugin in Vim. -- Added file: http://bugs.python.org/file31754/fix_overshadowed_test_in_testmock.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Michael Foord added the comment: Well, they actually test slightly different scenarios - they're *not* just duplicates of each other. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Vajrasky Kok added the comment: Okay, I found the difference. The second test case is to test the case on which we delete the attribute of the mock instance before being referenced by any variable. The we make sure the attribute is gone for good. The first test case is to test the case on which we delete the attribute of the mock instance after being referenced by any variable (or maybe just needed to be used by __getattr__), then we make sure the attribute is resetted to the original value, not deleted. I oversight this because I never thought that people could rely on this behaviour. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Michael Foord added the comment: Although I'm not certain the first test is invalid. It's testing a different case than the second test. So if the first test passes it should be renamed rather than removed. If it *fails* then I'd like to look at the behaviour and specify (test) that. -- assignee: - michael.foord versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Michael Foord added the comment: Good catch - thanks! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Changes by Antoine Pitrou pit...@free.fr: -- nosy: +ezio.melotti, michael.foord ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
Vajrasky Kok added the comment: The first test fails. I already tested it. I think they test the same thing, what happens to the attribute of mock instance if you delete it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18993] There is an overshadowed and invalid test in testmock.py
New submission from Vajrasky Kok: In Lib/unittest/test/testmock/testmock.py, there are two test_attribute_deletion. One of them is overshadowed (not executed) by the other. def test_attribute_deletion(self): # this behaviour isn't *useful*, but at least it's now tested... for Klass in Mock, MagicMock, NonCallableMagicMock, NonCallableMock: m = Klass() original = m.foo m.foo = 3 del m.foo self.assertEqual(m.foo, original) new = m.foo = Mock() del m.foo self.assertEqual(m.foo, new) def test_attribute_deletion(self): for mock in Mock(), MagicMock(): self.assertTrue(hasattr(mock, 'm')) del mock.m self.assertFalse(hasattr(mock, 'm')) del mock.f self.assertFalse(hasattr(mock, 'f')) self.assertRaises(AttributeError, getattr, mock, 'f') They are testing the same thing but with different expectations. The first one is invalid and should be removed. The patch altered a bit of the second test to incorporate more mock classes. -- components: Tests files: remove_wrongly_test_in_testmock.patch keywords: patch messages: 197424 nosy: vajrasky priority: normal severity: normal status: open title: There is an overshadowed and invalid test in testmock.py type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file31708/remove_wrongly_test_in_testmock.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18993 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com