def test_unhighlight_paren_bugs(self):
        """two previous bugs, parent didn't highlight until next render
        and paren didn't unhighlight until enter"""
        self.assertEqual(self.repl.rl_history.entries, [''])
        self.enter('(')
        self.assertEqual(self.repl.rl_history.entries, [''])
        screen = [">>> (",
                  "... "]
        self.assertEqual(self.repl.rl_history.entries, [''])
        self.assert_paint_ignoring_formatting(screen)
        self.assertEqual(self.repl.rl_history.entries, [''])

        with output_to_repl(self.repl):
            self.assertEqual(self.repl.rl_history.entries, [''])
            self.repl.process_event(')')
            self.assertEqual(self.repl.rl_history.entries, [''])
        screen = fsarray([cyan(">>> ") + on_magenta(bold(red('('))),
                         green("... ") + on_magenta(bold(red(')')))])
        self.assert_paint(screen, (1, 5))

        with output_to_repl(self.repl):
            self.repl.process_event(' ')
        screen = fsarray([cyan(">>> ") + yellow('('),
                         green("... ") + yellow(')') + bold(cyan(" "))])
        self.assert_paint(screen, (1, 6))
    def test_unhighlight_paren_bugs(self):
        """two previous bugs, parent didn't highlight until next render
        and paren didn't unhighlight until enter"""
        self.assertEqual(self.repl.rl_history.entries, [""])
        self.enter("(")
        self.assertEqual(self.repl.rl_history.entries, [""])
        screen = [">>> (", "... "]
        self.assertEqual(self.repl.rl_history.entries, [""])
        self.assert_paint_ignoring_formatting(screen)
        self.assertEqual(self.repl.rl_history.entries, [""])

        with output_to_repl(self.repl):
            self.assertEqual(self.repl.rl_history.entries, [""])
            self.repl.process_event(")")
            self.assertEqual(self.repl.rl_history.entries, [""])
        screen = fsarray(
            [
                cyan(">>> ") + on_magenta(bold(red("("))),
                green("... ") + on_magenta(bold(red(")"))),
            ]
        )
        self.assert_paint(screen, (1, 5))

        with output_to_repl(self.repl):
            self.repl.process_event(" ")
        screen = fsarray(
            [
                cyan(">>> ") + yellow("("),
                green("... ") + yellow(")") + bold(cyan(" ")),
            ]
        )
        self.assert_paint(screen, (1, 6))
Beispiel #3
0
 def test_argspec(self):
     def foo(x, y, z=10):
         "docstring!"
         pass
     argspec = inspection.getargspec('foo', foo) + [1]
     array = replpainter.formatted_argspec(argspec, 30, setup_config())
     screen = [(bold(cyan(u'foo'))+cyan(':')+cyan(' ')+cyan('(')+cyan('x') +
               yellow(',')+yellow(' ')+bold(cyan('y'))+yellow(',') +
               yellow(' ')+cyan('z')+yellow('=')+bold(cyan('10'))+yellow(')'))]
     self.assertFSArraysEqual(fsarray(array), fsarray(screen))
    def test_paint_lasts_events(self):
        actual = replpainter.paint_last_events(
            4, 100, ["a", "b", "c"], config=setup_config()
        )
        if config.supports_box_chars():
            expected = fsarray(["┌─┐", "│c│", "│b│", "└─┘"])
        else:
            expected = fsarray(["+-+", "|c|", "|b|", "+-+"])

        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
 def test_argspec(self):
     def foo(x, y, z=10):
         "docstring!"
         pass
     argspec = inspection.getfuncprops('foo', foo)
     array = replpainter.formatted_argspec(argspec, 1, 30, setup_config())
     screen = [bold(cyan('foo')) + cyan(':') + cyan(' ') + cyan('(') +
               cyan('x') + yellow(',') + yellow(' ') + bold(cyan('y')) +
               yellow(',') + yellow(' ') + cyan('z') + yellow('=') +
               bold(cyan('10')) + yellow(')')]
     self.assertFSArraysEqual(fsarray(array), fsarray(screen))
Beispiel #6
0
    def test_argspec(self):
        def foo(x, y, z=10):
            "docstring!"
            pass

        argspec = inspection.getfuncprops("foo", foo)
        array = replpainter.formatted_argspec(argspec, 1, 30, setup_config())
        screen = [
            bold(cyan("foo")) + cyan(":") + cyan(" ") + cyan("(") + cyan("x") +
            yellow(",") + yellow(" ") + bold(cyan("y")) + yellow(",") +
            yellow(" ") + cyan("z") + yellow("=") + bold(cyan("10")) +
            yellow(")")
        ]
        assertFSArraysEqual(fsarray(array), fsarray(screen))
    def test_paint_lasts_events(self):
        actual = replpainter.paint_last_events(4, 100, ['a', 'b', 'c'],
                                               config=setup_config())
        if config.supports_box_chars():
            expected = fsarray(["┌─┐",
                                "│c│",
                                "│b│",
                                "└─┘"])
        else:
            expected = fsarray(["+-+",
                                "|c|",
                                "|b|",
                                "+-+"])

        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
Beispiel #8
0
 def test_len_of_unicode(self):
     self.assertEqual(len(fmtstr('┌─')), 2)
     lines = ['┌─', 'an', '┌─']
     r = fsarray(lines)
     self.assertEqual(r.shape, (3, 2))
     self.assertEqual(len(fmtstr(fmtstr('┌─'))), len(fmtstr('┌─')))
     self.assertEqual(fmtstr(fmtstr('┌─')), fmtstr('┌─'))
Beispiel #9
0
 def test_formatted_docstring(self):
     actual = replpainter.formatted_docstring(
         'Returns the results\n\n' 'Also has side effects',
         40, config=setup_config())
     expected = fsarray(['Returns the results', '',
                         'Also has side effects'])
     self.assertFSArraysEqualIgnoringFormatting(actual, expected)
Beispiel #10
0
 def test_diff_testing(self):
     a = fsarray(["abc", "def"])
     b = fsarray(["abc", "dqf"])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue("abc"), red("def")])
     b = fsarray([blue("abc"), red("dqf")])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue("abc"), red("def")])
     b = fsarray([blue("abc"), red("d") + blue("e") + red("f")])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray(["abc", "def"])
     b = fsarray(["abc", "def"])
     self.assertFSArraysEqual(a, b)
     a = fsarray([blue("abc"), red("def")])
     b = fsarray([blue("abc"), red("def")])
     self.assertFSArraysEqual(a, b)
Beispiel #11
0
 def test_len_of_unicode(self):
     self.assertEqual(len(fmtstr("┌─")), 2)
     lines = ["┌─", "an", "┌─"]
     r = fsarray(lines)
     self.assertEqual(r.shape, (3, 2))
     self.assertEqual(len(fmtstr(fmtstr("┌─"))), len(fmtstr("┌─")))
     self.assertEqual(fmtstr(fmtstr("┌─")), fmtstr("┌─"))
Beispiel #12
0
 def test_diff_testing(self):
     a = fsarray(['abc', 'def'])
     b = fsarray(['abc', 'dqf'])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('dqf')])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('d') + blue('e') + red('f')])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray(['abc', 'def'])
     b = fsarray(['abc', 'def'])
     self.assertFSArraysEqual(a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('def')])
     self.assertFSArraysEqual(a, b)
Beispiel #13
0
 def test_len_of_unicode(self):
     self.assertEqual(len(fmtstr('┌─')), 2)
     lines = ['┌─', 'an', '┌─']
     r = fsarray(lines)
     self.assertEqual(r.shape, (3, 2))
     self.assertEqual(len(fmtstr(fmtstr('┌─'))), len(fmtstr('┌─')))
     self.assertEqual(fmtstr(fmtstr('┌─')), fmtstr('┌─'))
Beispiel #14
0
 def test_paint_lasts_events(self):
     actual = replpainter.paint_last_events(4, 100, ['a', 'b', 'c'], config=setup_config())
     expected = fsarray(["┌─┐",
                         "│c│",
                         "│b│",
                         "└─┘"])
     self.assertFSArraysEqualIgnoringFormatting(actual, expected)
Beispiel #15
0
 def test_diff_testing(self):
     a = fsarray(['abc', 'def'])
     b = fsarray(['abc', 'dqf'])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('dqf')])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('d')+blue('e')+red('f')])
     self.assertRaises(AssertionError, self.assertFSArraysEqual, a, b)
     a = fsarray(['abc', 'def'])
     b = fsarray(['abc', 'def'])
     self.assertFSArraysEqual(a, b)
     a = fsarray([blue('abc'), red('def')])
     b = fsarray([blue('abc'), red('def')])
     self.assertFSArraysEqual(a, b)
 def test_formatted_docstring(self):
     actual = replpainter.formatted_docstring(
         'Returns the results\n\n' 'Also has side effects',
         40, config=setup_config())
     expected = fsarray(['Returns the results', '',
                         'Also has side effects'])
     self.assertFSArraysEqualIgnoringFormatting(actual, expected)
 def test_formatted_docstring(self):
     actual = replpainter.formatted_docstring(
         "Returns the results\n\n" "Also has side effects",
         40,
         config=setup_config(),
     )
     expected = fsarray(["Returns the results", "", "Also has side effects"])
     self.assertFSArraysEqualIgnoringFormatting(actual, expected)
 def test_enter_text(self):
     [self.repl.add_normal_character(c) for c in '1 + 1']
     screen = fsarray([
         cyan('>>> ') + bold(
             green('1') + cyan(' ') + yellow('+') + cyan(' ') + green('1')),
         cyan('Welcome to')
     ])
     self.assert_paint(screen, (0, 9))
Beispiel #19
0
 def test_enter_text(self):
     [self.repl.add_normal_character(c) for c in "1 + 1"]
     screen = fsarray([
         cyan(">>> ") + bold(
             green("1") + cyan(" ") + yellow("+") + cyan(" ") + green("1")),
         cyan("Welcome to"),
     ])
     self.assert_paint(screen, (0, 9))
 def test_run_line(self):
     try:
         orig_stdout = sys.stdout
         sys.stdout = self.repl.stdout
         [self.repl.add_normal_character(c) for c in '1 + 1']
         self.repl.on_enter(insert_into_history=False)
         screen = fsarray(['>>> 1 + 1', '2', 'Welcome to'])
         self.assert_paint_ignoring_formatting(screen, (1, 1))
     finally:
         sys.stdout = orig_stdout
 def test_run_line(self):
     try:
         orig_stdout = sys.stdout
         sys.stdout = self.repl.stdout
         [self.repl.add_normal_character(c) for c in '1 + 1']
         self.repl.on_enter(insert_into_history=False)
         screen = fsarray(['>>> 1 + 1', '2', 'Welcome to'])
         self.assert_paint_ignoring_formatting(screen, (1, 1))
     finally:
         sys.stdout = orig_stdout
 def test_run_line(self):
     try:
         orig_stdout = sys.stdout
         sys.stdout = self.repl.stdout
         [self.repl.add_normal_character(c) for c in "1 + 1"]
         self.repl.on_enter(new_code=False)
         screen = fsarray([">>> 1 + 1", "2", "Welcome to"])
         self.assert_paint_ignoring_formatting(screen, (1, 1))
     finally:
         sys.stdout = orig_stdout
    def test_unicode_docstrings(self):
        "A bit of a special case in Python 2"
        # issue 653

        def foo():
            u"åß∂ƒ"

        actual = replpainter.formatted_docstring(
                     foo.__doc__, 40, config=setup_config())
        expected = fsarray([u'åß∂ƒ'])
        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
    def test_unicode_docstrings(self):
        "A bit of a special case in Python 2"
        # issue 653

        def foo():
            "åß∂ƒ"

        actual = replpainter.formatted_docstring(
            foo.__doc__, 40, config=setup_config()
        )
        expected = fsarray(["åß∂ƒ"])
        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
    def test_weird_boto_docstrings(self):
        # Boto does something like this.
        # botocore: botocore/docs/docstring.py
        class WeirdDocstring(str):
            # a mighty hack. See botocore/docs/docstring.py
            def expandtabs(self, tabsize=8):
                return u'asdfåß∂ƒ'.expandtabs(tabsize)

        def foo():
            pass

        foo.__doc__ = WeirdDocstring()
        wd = pydoc.getdoc(foo)
        actual = replpainter.formatted_docstring(wd, 40, config=setup_config())
        expected = fsarray([u'asdfåß∂ƒ'])
        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
    def test_weird_boto_docstrings(self):
        # Boto does something like this.
        # botocore: botocore/docs/docstring.py
        class WeirdDocstring(str):
            # a mighty hack. See botocore/docs/docstring.py
            def expandtabs(self, tabsize=8):
                return "asdfåß∂ƒ".expandtabs(tabsize)

        def foo():
            pass

        foo.__doc__ = WeirdDocstring()
        wd = pydoc.getdoc(foo)
        actual = replpainter.formatted_docstring(wd, 40, config=setup_config())
        expected = fsarray(["asdfåß∂ƒ"])
        self.assertFSArraysEqualIgnoringFormatting(actual, expected)
 def test_enter_text(self):
     [self.repl.add_normal_character(c) for c in '1 + 1']
     screen = fsarray([cyan('>>> ') + bold(green('1') + cyan(' ') +
                       yellow('+') + cyan(' ') + green('1')),
                       cyan('Welcome to')])
     self.assert_paint(screen, (0, 9))
 def test_startup(self):
     screen = fsarray([cyan('>>> '), cyan('Welcome to')])
     self.assert_paint(screen, (0, 4))
Beispiel #29
0
 def test_oomerror(self):
     a = FSArray(10, 40)
     a[2:-2, 2:-2] = fsarray(["asdf", "zxcv"])
 def test_startup(self):
     screen = fsarray([cyan('>>> '), cyan('Welcome to')])
     self.assert_paint(screen, (0, 4))
Beispiel #31
0
 def test_oomerror(self):
     a = FSArray(10, 40)
     a[2:-2, 2:-2] = fsarray(['asdf', 'zxcv'])
Beispiel #32
0
 def test_oomerror(self):
     a = FSArray(10, 40)
     a[2:-2, 2:-2] = fsarray(['asdf', 'zxcv'])
 def test_startup(self):
     screen = fsarray([cyan(">>> "), cyan("Welcome to")])
     self.assert_paint(screen, (0, 4))