4
4
import os
5
5
from contextlib import contextmanager
6
6
7
- try :
8
- import unittest2 as unittest
9
- except ImportError :
10
- import unittest
11
-
12
7
from curtsies .formatstringarray import FormatStringTest , fsarray
13
8
from curtsies .fmtfuncs import cyan , bold , green , yellow , on_magenta , red
14
9
from bpython .curtsiesfrontend .events import RefreshRequestEvent
20
15
from bpython .curtsiesfrontend .repl import INCONSISTENT_HISTORY_MSG , CONTIGUITY_BROKEN_MSG
21
16
from bpython .test import FixLanguageTestCase as TestCase
22
17
18
+
23
19
def setup_config ():
24
20
config_struct = config .Struct ()
25
21
config .loadini (config_struct , os .devnull )
26
22
return config_struct
27
23
24
+
28
25
class TestCurtsiesPainting (FormatStringTest , TestCase ):
29
26
def setUp (self ):
30
27
self .repl = Repl (config = setup_config ())
@@ -42,11 +39,13 @@ def assert_paint_ignoring_formatting(self, screen, cursor_row_col=None):
42
39
if cursor_row_col is not None :
43
40
self .assertEqual (cursor_pos , cursor_row_col )
44
41
42
+
45
43
class TestCurtsiesPaintingTest (TestCurtsiesPainting ):
46
44
47
45
def test_history_is_cleared (self ):
48
46
self .assertEqual (self .repl .rl_history .entries , ['' ])
49
47
48
+
50
49
class TestCurtsiesPaintingSimple (TestCurtsiesPainting ):
51
50
52
51
def test_startup (self ):
@@ -122,6 +121,7 @@ def test_paint_lasts_events(self):
122
121
123
122
self .assertFSArraysEqualIgnoringFormatting (actual , expected )
124
123
124
+
125
125
@contextmanager
126
126
def output_to_repl (repl ):
127
127
old_out , old_err = sys .stdout , sys .stderr
@@ -131,6 +131,7 @@ def output_to_repl(repl):
131
131
finally :
132
132
sys .stdout , sys .stderr = old_out , old_err
133
133
134
+
134
135
class TestCurtsiesRewindRedraw (TestCurtsiesPainting ):
135
136
def refresh (self ):
136
137
self .refresh_requests .append (RefreshRequestEvent ())
0 commit comments