Ejemplo n.º 1
0
    def test_wrong_usage_of_assert_called_once_from_mock(self):
        fake_method = "rtfm.assert_called_once()"

        actual_number, actual_msg = next(checks.check_assert_methods_from_mock(
            fake_method, "./tests/fake/test"))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith("N303"))
Ejemplo n.º 2
0
    def test_wrong_usage_of_broad_assert_from_mock(self):
        fake_method = "rtfm.assert_something()"

        actual_number, actual_msg = next(checks.check_assert_methods_from_mock(
            fake_method, fake_method, "./tests/fake/test"))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith("N301"))
Ejemplo n.º 3
0
 def test_correct_usage_of_assert_from_mock(self):
     correct_method_names = ["assert_any_call", "assert_called_once_with",
                             "assert_called_with", "assert_has_calls"]
     for name in correct_method_names:
         self.assertEqual(0, len(
             list(checks.check_assert_methods_from_mock(
                 "some_mock.%s(asd)" % name, "./tests/fake/test"))))
Ejemplo n.º 4
0
    def test_wrong_usage_of_assert_called_from_mock(self):
        fake_method = 'rtfm.assert_called()'

        actual_number, actual_msg = next(checks.check_assert_methods_from_mock(
            fake_method, './tests/fake/test'))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith('N302'))
Ejemplo n.º 5
0
    def test_wrong_usage_of_broad_assert_from_mock(self):
        fake_method = "rtfm.assert_something()"

        actual_number, actual_msg = next(checks.check_assert_methods_from_mock(
            fake_method, fake_method, "./tests/fake/test"))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith("N301"))
Ejemplo n.º 6
0
    def test_wrong_usage_of_assert_called_once_from_mock(self):
        fake_method = "rtfm.assert_called_once()"

        actual_number, actual_msg = next(
            checks.check_assert_methods_from_mock(fake_method,
                                                  "./tests/fake/test"))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith("N303"))
Ejemplo n.º 7
0
    def test_wrong_usage_of_assert_called_from_mock(self):
        fake_method = 'rtfm.assert_called()'

        actual_number, actual_msg = next(
            checks.check_assert_methods_from_mock(fake_method,
                                                  'tests/fake/test'))
        self.assertEqual(4, actual_number)
        self.assertTrue(actual_msg.startswith('N302'))
Ejemplo n.º 8
0
 def test_correct_usage_of_assert_from_mock(self):
     correct_method_names = ["assert_any_call", "assert_called_once_with",
                             "assert_called_with", "assert_has_calls"]
     for name in correct_method_names:
         line = "some_mock.%s(asd)" % name
         self.assertEqual(0, len(
             list(checks.check_assert_methods_from_mock(
                 line, line, "./tests/fake/test"))))