예제 #1
0
 def test_version_conflict_in_collecting_bears(self, import_fn):
     with bear_test_module():
         import_fn.side_effect = (
             lambda *args, **kwargs: raise_error(VersionConflict,
                                                 "msg1", "msg2"))
         retval, output = execute_coala(coala.main, "coala", "-A")
         self.assertEqual(retval, 13)
         self.assertIn(("There is a conflict in the version of a "
                        "dependency you have installed"), output)
         self.assertIn("pip install msg2", output)  # Check recommendation
예제 #2
0
    def test_unimportable_bear(self, import_fn):
        with bear_test_module():
            import_fn.side_effect = (
                lambda *args, **kwargs: raise_error(SyntaxError))
            retval, output = execute_coala(coala.main, "coala", "-A")
            self.assertEqual(retval, 0)
            self.assertIn("Unable to collect bears from", output)

            import_fn.side_effect = (
                lambda *args, **kwargs: raise_error(VersionConflict,
                                                    "msg1", "msg2"))
            retval, output = execute_coala(coala.main, "coala", "-A")
            # Note that bear version conflicts don't give exitcode=13,
            # they just give a warning with traceback in log_level debug.
            self.assertEqual(retval, 0)
            self.assertRegex(output,
                             "Unable to collect bears from .* because there "
                             "is a conflict with the version of a dependency "
                             "you have installed")
            self.assertIn("pip install msg2", output)  # Check recommendation
예제 #3
0
파일: TaggingTest.py 프로젝트: yland/coala
    def test_permission_error(self):
        old_makedirs = os.makedirs
        os.makedirs = lambda *args, **kwargs: raise_error(PermissionError)

        self.assertEqual(get_tag_path("a", "b", self.log_printer), None)
        tag_results("test_tag", "test_path", {}, self.log_printer)
        results = load_tagged_results("test_tag",
                                      "test_path",
                                      self.log_printer)
        self.assertEqual(results, None)

        os.makedirs = old_makedirs
예제 #4
0
    def test_ask_for_actions_and_apply(self):
        failed_actions = set()
        action = TestAction()
        args = [self.log_printer, self.console_printer, Section(""),
                [action.get_metadata()], {'TestAction': action},
                failed_actions, Result("origin", "message"), {}, {}]

        with simulate_console_inputs(1, 'param1', 1, 'param2') as generator:
            action.apply = lambda *args, **kwargs: raise_error(AssertionError)
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 1)
            self.assertIn('TestAction', failed_actions)

            action.apply = lambda *args, **kwargs: {}
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 3)
            self.assertNotIn('TestAction', failed_actions)
    def test_ask_for_actions_and_apply(self):
        failed_actions = set()
        action = TestAction()
        args = [self.log_printer, self.console_printer, Section(""),
                [action.get_metadata()], {'TestAction': action},
                failed_actions, Result("origin", "message"), {}, {}]

        with simulate_console_inputs(1, 'param1', 1, 'param2') as generator:
            action.apply = lambda *args, **kwargs: raise_error(AssertionError)
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 1)
            self.assertIn('TestAction', failed_actions)

            action.apply = lambda *args, **kwargs: {}
            ask_for_action_and_apply(*args)
            self.assertEqual(generator.last_input, 3)
            self.assertNotIn('TestAction', failed_actions)