「testable.py」という 2 つのファイルがあります。
def joiner(x,y):
return x+y
"test_testable.py":
import unittest
import testable
class TestTestable(unittest.TestCase):
def setUp(self):
self.seq = ['a','b','1']
self.seq2 = ['b','c',1]
def test_joiner(self):
for each in self.seq:
for eachy in self.seq2:
self.assertRaises(TypeError,testable.joiner(each,eachy))
if __name__ == '__main__':
unittest.main()
テストを実行すると、次のようになります。
ERROR: test_joiner (test_testable.TestTestable)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/rajat/collective_knowledge/test_testable.py", line 16, in test_joiner
self.assertRaises(TypeError,testable.joiner(each,eachy),(each,eachy))
File "/home/rajat/collective_knowledge/testable.py", line 11, in joiner
return x+y
TypeError: cannot concatenate 'str' and 'int' objects
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
私は何を間違っていますか?