def _test_text(self, text_buffer, line_slice, sub_string):

        raw_text_document = RawTextDocument(text_buffer)
        lines = raw_text_document.lines(new_line_separator=False)
        self.assertEqual(len(lines), len(text_buffer.splitlines()))
        lines = raw_text_document.lines()
        self.assertEqual(len(text_buffer), sum([len(x) for x in lines]))
        self.assertEqual(raw_text_document.substring(FlatSlice(5, 10)), text_buffer[5:10])
        self.assertEqual(raw_text_document.substring(line_slice), sub_string)
    def _test_text(self, text_buffer, line_slice, sub_string):

        raw_text_document = RawTextDocument(text_buffer)
        lines = raw_text_document.lines(new_line_separator=False)
        self.assertEqual(len(lines), len(text_buffer.splitlines()))
        lines = raw_text_document.lines()
        self.assertEqual(len(text_buffer), sum([len(x) for x in lines]))
        self.assertEqual(raw_text_document.substring(FlatSlice(5, 10)),
                         text_buffer[5:10])
        self.assertEqual(raw_text_document.substring(line_slice), sub_string)
    def test(self):

        test_file_path = os.path.join(os.path.dirname(__file__), 'data', 'test_file1.py')
        with open(test_file_path) as f:
            text = f.read()

        raw_text_document = RawTextDocument(text)

        lexer = get_lexer_for_filename(test_file_path, stripnl=False)
        highlighted_text = HighlightedText(raw_text_document, lexer)

        for fragment in highlighted_text:
            print(repr(fragment), '[' + raw_text_document.substring(fragment.slice) + ']')
    def test(self):

        test_file_path = os.path.join(os.path.dirname(__file__), 'data',
                                      'test_file1.py')
        with open(test_file_path) as f:
            text = f.read()

        raw_text_document = RawTextDocument(text)

        lexer = get_lexer_for_filename(test_file_path, stripnl=False)
        highlighted_text = HighlightedText(raw_text_document, lexer)

        for fragment in highlighted_text:
            print(repr(fragment),
                  '[' + raw_text_document.substring(fragment.slice) + ']')