コード例 #1
0
    def test_danger_display_uses_formatter(self):
        score = Score(danger=2)
        score.rating_display = Mock(return_value='2')

        display_value = score.danger_display

        score.rating_display.assert_called_with(2)
        self.assertEqual(display_value, '2')
コード例 #2
0
    def test_pseudoscience_display_uses_formatter(self):
        score = Score(pseudoscience=2)
        score.rating_display = Mock(return_value='2')

        display_value = score.pseudoscience_display

        score.rating_display.assert_called_with(2)
        self.assertEqual(display_value, '2')
コード例 #3
0
    def test_creepiness_display_uses_formatter(self):
        score = Score(creepiness=2)
        score.rating_display = Mock(return_value='2')

        display_value = score.creepiness_display

        score.rating_display.assert_called_with(2)
        self.assertEqual(display_value, '2')
コード例 #4
0
 def test_rating_display_removes_unnecessary_zeros_and_decimals(self):
     display_number = Score.rating_display(3.00000)
     self.assertEqual(display_number, '3')
     display_number = Score.rating_display(3.1000)
     self.assertEqual(display_number, '3.1')
コード例 #5
0
 def test_rating_display_rounds_float(self):
     display_number = Score.rating_display(3.1415)
     self.assertEqual(display_number, '3.14')
コード例 #6
0
 def test_rating_display_shows_an_integer_as_is(self):
     display_two = Score.rating_display(2)
     display_ten = Score.rating_display(10)
     self.assertEqual(display_two, '2')
     self.assertEqual(display_ten, '10')