AssertionError: Expected 'tweet_to_twitter' to be called once. Called 0 times.
テストが通りません...
何故呼ばれていないのでしょうか...?
test_handler.py
python
1test_handler.py 2import unittest 3import mock 4class TestTweetToTwitter(unittest.TestCase): 5 def test_tweet(self): 6 with mock.patch(lib.twitter) as twitter: 7 tweet_to_twitter("test") 8 twitter.tweet_to_twitter.assert_called_once_with("test") 9
lib/twitter.py
python
1 2lib/twitter.py 3class Twitter(): 4 def __init__(self): 5 """Initialize.""" 6 7 def tweet_to_twitter(self, message): 8 """Post message to room."""
提示されているtest_handler.pyのコードは実際のコードのように見えません。mock.patchの引数は文字列ではないですか?また、tweet_to_twitterという関数はこのtest_handler.pyにないのでNameErrorになりませんか?