44import os
55from contextlib import contextmanager
66
7- try :
8- import unittest2 as unittest
9- except ImportError :
10- import unittest
11-
127from curtsies .formatstringarray import FormatStringTest , fsarray
138from curtsies .fmtfuncs import cyan , bold , green , yellow , on_magenta , red
149from bpython .curtsiesfrontend .events import RefreshRequestEvent
2015from bpython .curtsiesfrontend .repl import INCONSISTENT_HISTORY_MSG , CONTIGUITY_BROKEN_MSG
2116from bpython .test import FixLanguageTestCase as TestCase
2217
18+
2319def setup_config ():
2420 config_struct = config .Struct ()
2521 config .loadini (config_struct , os .devnull )
2622 return config_struct
2723
24+
2825class TestCurtsiesPainting (FormatStringTest , TestCase ):
2926 def setUp (self ):
3027 self .repl = Repl (config = setup_config ())
@@ -42,11 +39,13 @@ def assert_paint_ignoring_formatting(self, screen, cursor_row_col=None):
4239 if cursor_row_col is not None :
4340 self .assertEqual (cursor_pos , cursor_row_col )
4441
42+
4543class TestCurtsiesPaintingTest (TestCurtsiesPainting ):
4644
4745 def test_history_is_cleared (self ):
4846 self .assertEqual (self .repl .rl_history .entries , ['' ])
4947
48+
5049class TestCurtsiesPaintingSimple (TestCurtsiesPainting ):
5150
5251 def test_startup (self ):
@@ -122,6 +121,7 @@ def test_paint_lasts_events(self):
122121
123122 self .assertFSArraysEqualIgnoringFormatting (actual , expected )
124123
124+
125125@contextmanager
126126def output_to_repl (repl ):
127127 old_out , old_err = sys .stdout , sys .stderr
@@ -131,6 +131,7 @@ def output_to_repl(repl):
131131 finally :
132132 sys .stdout , sys .stderr = old_out , old_err
133133
134+
134135class TestCurtsiesRewindRedraw (TestCurtsiesPainting ):
135136 def refresh (self ):
136137 self .refresh_requests .append (RefreshRequestEvent ())
0 commit comments