def test_parse(self): '''tests parse with a small spread in bayesian match values''' config = TestConfig() ProgrammingParser.bootstrap(config) self.bootstrapMock.assert_called_with(config) parser = ProgrammingParser(config) expected_types = [ 'Visual Basic', 'Python', 'PHP' ] results = [] for result in parser.parse('with cout echo'): self.assertIsInstance(result, ParseResult) results.append(result) self.assertEqual(3, len(results)) for result in results: self.assertIn(result.subtype, expected_types) self.smallSpreadClassifyMock.assert_called_once_with('with cout echo')
def test_parseWithLargeDeepNegativeSpread(self): '''tests parse with a large spread in bayesian match values''' config = TestConfig() ProgrammingParser.bootstrap(config) self.bootstrapMock.assert_called_with(config) parser = ProgrammingParser(config) expected_types = ( 'Visual Basic', 'JavaScript', 'ActionScript', 'Python', 'PHP' ) results = [] for result in parser.parse('with cout echo'): self.assertIsInstance(result, ParseResult) results.append(result) self.assertEqual(5, len(results)) for result in results: self.assertIn(result.subtype, expected_types) self.bigSpreadClassifyMock.assert_called_once_with('with cout echo')
def test_parseWithNoLexedLanguagesReturns(self): config = TestConfig() ProgrammingParser.bootstrap(config) self.bootstrapMock.assert_called_with(config) parser = ProgrammingParser(config) count = 0 for _ in parser.parse('m foo bar'): count += 1 self.assertEqual(0, count)
def test_parseWithNoCommonTokensReturns(self): config = TestConfig() ProgrammingParser.bootstrap(config) self.bootstrapMock.assert_called_with(config) parser = ProgrammingParser(config) count = 0 for _ in parser.parse('scoobydoo'): count += 1 self.assertEqual(0, count)