bpo-27071: rename assertCountEqual to assertPermutation by graingert · Pull Request #16228 · python/cpython (original) (raw)
Tests fail because aliasing somehow did not work.
ERROR: testAssertPermutation (unittest.test.test_case.Test_TestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "d:\a\1\s\lib\unittest\test\test_case.py", line 995, in testAssertPermutation self.assertEqual(self.assertCountEqual, self.assertPermutation) AttributeError: 'Test_TestCase' object has no attribute 'assertCountEqual'
It was a typo in my alias
Besides which, the assertion should be
assertIs
.
no it has to be assertEqual because methods do not compare is
:
import unittest
class Ham: def spam(self): pass
eggs = spam
def bacon(self):
pass
class TestHam(unittest.TestCase): def test_eggs_is_eggs(self): h = Ham() self.assertIs(h.eggs, h.eggs)
def test_spam_is_spam(self):
h = Ham()
self.assertIs(h.spam, h.spam)
def test_spam_is_eggs(self):
h = Ham()
self.assertIs(h.spam, h.eggs)
def test_eggs_equal_eggs(self):
h = Ham()
self.assertEqual(h.eggs, h.eggs)
def test_spam_equal_spam(self):
h = Ham()
self.assertEqual(h.spam, h.spam)
def test_spam_equal_eggs(self):
h = Ham()
self.assertEqual(h.spam, h.eggs)
def test_spam_equal_bacon(self):
h = Ham()
self.assertEqual(h.spam, h.bacon)
if name == "main": unittest.main()
test_eggs_equal_eggs (__main__.TestHam) ... ok
test_eggs_is_eggs (__main__.TestHam) ... FAIL
test_spam_equal_bacon (__main__.TestHam) ... FAIL
test_spam_equal_eggs (__main__.TestHam) ... ok
test_spam_equal_spam (__main__.TestHam) ... ok
test_spam_is_eggs (__main__.TestHam) ... FAIL
test_spam_is_spam (__main__.TestHam) ... FAIL
======================================================================
FAIL: test_eggs_is_eggs (__main__.TestHam)
----------------------------------------------------------------------
Traceback (most recent call last):
File "foo.py", line 17, in test_eggs_is_eggs
self.assertIs(h.eggs, h.eggs)
AssertionError: <bound method Ham.spam of <__main__.Ham object at 0x7f85b504feb0>> is not <bound method Ham.spam of <__main__.Ham object at 0x7f85b504feb0>>
======================================================================
FAIL: test_spam_equal_bacon (__main__.TestHam)
----------------------------------------------------------------------
Traceback (most recent call last):
File "foo.py", line 41, in test_spam_equal_bacon
self.assertEqual(h.spam, h.bacon)
AssertionError: <bound method Ham.spam of <__main__.Ham object at 0x7f85b504ff70>> != <bound method Ham.bacon of <__main__.Ham object at 0x7f85b504ff70>>
======================================================================
FAIL: test_spam_is_eggs (__main__.TestHam)
----------------------------------------------------------------------
Traceback (most recent call last):
File "foo.py", line 25, in test_spam_is_eggs
self.assertIs(h.spam, h.eggs)
AssertionError: <bound method Ham.spam of <__main__.Ham object at 0x7f85b504feb0>> is not <bound method Ham.spam of <__main__.Ham object at 0x7f85b504feb0>>
======================================================================
FAIL: test_spam_is_spam (__main__.TestHam)
----------------------------------------------------------------------
Traceback (most recent call last):
File "foo.py", line 21, in test_spam_is_spam
self.assertIs(h.spam, h.spam)
AssertionError: <bound method Ham.spam of <__main__.Ham object at 0x7f85b504ff70>> is not <bound method Ham.spam of <__main__.Ham object at 0x7f85b504ff70>>
----------------------------------------------------------------------
Ran 7 tests in 0.001s
FAILED (failures=4)