Example #1
0
 def setUp(self):
     self.section1 = Section('')
     self.section1.append(Setting('language', 'python 3'))
     self.python_uut = AnnotationBear(self.section1, Queue())
     self.section2 = Section('')
     self.section2.append(Setting('language', 'c'))
     self.c_uut = AnnotationBear(self.section2, Queue())
Example #2
0
 def test_no_coalang(self):
     self.section1.append(Setting('language', 'Valyrian'))
     text = ['Valar Morghulis']
     uut = AnnotationBear(self.section1, Queue())
     with execute_bear(uut, 'F', text) as result:
         self.assertEqual(result[0].contents,
                          'coalang specification for Valyrian not found.')
 def test_external_coalang(self):
     self.section1.append(
         Setting(
             'coalang_dir',
             escape(os.path.join(os.path.dirname(__file__), 'test_files'),
                    '\\')))
     self.section1.append(Setting('language', 'test'))
     uut = AnnotationBear(self.section1, Queue())
     text = ['//comment line 1\n', '"""string line 2"""']
     with execute_bear(uut, "F", text) as result:
         self.assertNotEqual(result[0].contents['strings'], ())
         self.assertNotEqual(result[0].contents['comments'], ())
Example #4
0
    def test_escape_strings(self):
        text = [r"'I\'ll be back' -T1000"]
        uut = AnnotationBear(self.section1, Queue())
        test_range = SourceRange.from_absolute_position(
            'F',
            AbsolutePosition(text, 0),
            AbsolutePosition(text, text[0].find("'", 4)))
        with execute_bear(uut, 'F', text) as result:
            self.assertEqual(result[0].contents['strings'], (test_range,))

        text = ['''
            """"quoting inside quoting"
            """
            ''']
        uut = AnnotationBear(self.section1, Queue())
        with execute_bear(uut, 'F', text) as results:
            for result in results:
                # The """" was recognized as a string start and end before.
                # That lead to a Result being yielded because of unclosed
                # quotes, this asserts that no such thing happened.
                self.assertEqual(type(result), HiddenResult)
 def setUp(self):
     self.section = Section('')
     self.section.append(Setting('language', 'TestLanguage'))
     self.section.append(Setting('use_spaces', False))
     self.dep_uut = AnnotationBear(self.section, Queue())