何も返さない関数をテストするにはどうすればよいですか?
たとえば、次の関数があるとします。
def is_in(char):
my_list = []
my_list.append(char)
そして、私がそれをテストするとしたら:
class TestIsIn(unittest.TestCase):
def test_one(self):
''' Test if one character was added to the list'''
self.assertEqual(self.is_in('a'), # And this is where I am lost)
比較できる戻り値がないため、関数が等しいと断言する方法がわかりません。
assertIn は機能しますか?