def test_missing_dependency_parser_importerror_in_debug_mode(self, logs): logging.disable(logging.NOTSET) # turn on debug mode log = logging.getLogger('WakaTime') log.setLevel(logging.DEBUG) with mock.patch('wakatime.dependencies.import_module') as mock_import: mock_import.side_effect = ImportError('foo') lexer = PythonLexer lexer.__class__.__name__ = 'FooClass' parser = DependencyParser(None, lexer) # parse dependencies dependencies = parser.parse() log_output = u("\n").join([u(' ').join(x) for x in logs.actual()]) expected = 'WakaTime DEBUG Parsing dependencies not supported for python.FooClass' self.assertEquals(log_output, expected) self.assertNothingPrinted() expected = [] self.assertEquals(dependencies, expected)
def test_dependency_parser(self, logs): logging.disable(logging.NOTSET) lexer = PythonLexer lexer.__class__.__name__ = 'FooClass' parser = DependencyParser(None, lexer) dependencies = parser.parse() log_output = u("\n").join([u(' ').join(x) for x in logs.actual()]) self.assertEquals(log_output, '') self.assertNothingPrinted() expected = [] self.assertEquals(dependencies, expected)
def test_missing_dependency_parser_in_debug_mode(self, logs): logging.disable(logging.NOTSET) # turn on debug mode log = logging.getLogger('WakaTime') log.setLevel(logging.DEBUG) lexer = PythonLexer lexer.__class__.__name__ = 'FooClass' parser = DependencyParser(None, lexer) # parse dependencies dependencies = parser.parse() log_output = u("\n").join([u(' ').join(x) for x in logs.actual()]) expected = 'WakaTime DEBUG Parsing dependencies not supported for python.FooClass' self.assertEquals(log_output, expected) self.assertEquals(sys.stdout.getvalue(), '') self.assertEquals(sys.stderr.getvalue(), '') expected = [] self.assertEquals(dependencies, expected)