... e. """ time = timezone . now () + datetime . timedelta ( days = 30 ) future_question = Question ( pub_date = time ) self . assertIs ( future_question . was_published_recently (), False ) ここでは、未来の日付の pub_date を持つ Question のインスタンスを生成 ... ast ) : File "/path/to/djangotutorial/polls/tests.py" , line 16 , in test_was_published_recently_with_future_question self.assertIs ( future_question.was_published_recently () , False ) AssertionError: True is not False ---------------------------------- ... uture_question の中で、 pub_date フィールドに今日から30日後の日付を持つ Question インスタンスが作成されます そして最後に、 assertIs() メソッドを使うことで、本当に返してほしいのは False だったにもかかわらず、 was_published_recently() が True を返しているこ ... ... ption or warning message. Use assertRaisesRegex() and assertWarnsRegex() only if you need regular expression matching. Use assertIs(…, True/False) for testing boolean values, rather than assertTrue() and assertFalse() , so you can check the actual boolea ... ... subject , "I am content." , from_email , [ to ]) msg . attach_alternative ( "<p>I am content.</p>" , "text/html" ) self . assertIs ( msg . body_contains ( "I am content" ), True ) self . assertIs ( msg . body_contains ( "<p>I am content.</p>" ), False ) ... ... iew ) # Class-based views need to compare the view_class, as the # functions generated by as_view() won't be equal. self . assertIs ( response . resolver_match . func . view_class , MyView ) 指定された URL が見つからない場合、この属性にアクセスすると Res ... estModelDefinition ( SimpleTestCase ): def test_model_definition ( self ): class TestModel ( models . Model ): pass self . assertIs ( self . apps . get_model ( "app_label" , "TestModel" ), TestModel ) あるいは、 kwarg_name パラメータを使ってメソッドデコレ ... _label" , kwarg_name = "apps" ) def test_model_definition ( self , apps ): class TestModel ( models . Model ): pass self . assertIs ( apps . get_model ( "app_label" , "TestModel" ), TestModel ) テスト用の送信トレイを空にする Django のカスタムの TestCase ... ... st recent call last ) : File "/dev/mysite/polls/tests.py" , line 16 , in test_was_published_recently_with_future_poll self.assertIs ( future_poll.was_published_recently () , False ) AssertionError: True is not False -------------------------------------- ... 2026年10月08日