[New-bugs-announce] [issue18993] There is an overshadowed and invalid test in testmock.py
Vajrasky Kok
report at bugs.python.org
Tue Sep 10 08:55:03 CEST 2013
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 <report at bugs.python.org>
<http://bugs.python.org/issue18993>
_______________________________________
More information about the New-bugs-announce
mailing list