Skip to content

Commit 50d2b21

Browse files
prevent tests failing when PYTHONSTARTUP set
also rename poorly named parent test class
1 parent a3f43ba commit 50d2b21

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

bpython/test/test_curtsies_painting.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
from curtsies.formatstringarray import FormatStringTest, fsarray
88
from curtsies.fmtfuncs import cyan, bold, green, yellow, on_magenta, red
9-
from bpython.curtsiesfrontend.events import RefreshRequestEvent
109

10+
from bpython.curtsiesfrontend.events import RefreshRequestEvent
11+
from bpython.test import mock
1112
from bpython import config, inspection
1213
from bpython.curtsiesfrontend.repl import Repl
1314
from bpython.curtsiesfrontend import replpainter
@@ -23,7 +24,21 @@ def setup_config():
2324
return config_struct
2425

2526

26-
class TestCurtsiesPainting(FormatStringTest, TestCase):
27+
class ClearEnviron(TestCase):
28+
29+
@classmethod
30+
def setUpClass(cls):
31+
cls.mock_environ = mock.patch.dict('os.environ', {}, clear=True)
32+
cls.mock_environ.start()
33+
TestCase.setUpClass()
34+
35+
@classmethod
36+
def tearDownClass(cls):
37+
cls.mock_environ.stop()
38+
TestCase.tearDownClass()
39+
40+
41+
class CurtsiesPaintingTest(FormatStringTest, ClearEnviron):
2742
def setUp(self):
2843
self.repl = Repl(config=setup_config())
2944
# clear history
@@ -42,13 +57,13 @@ def assert_paint_ignoring_formatting(self, screen, cursor_row_col=None):
4257
self.assertEqual(cursor_pos, cursor_row_col)
4358

4459

45-
class TestCurtsiesPaintingTest(TestCurtsiesPainting):
60+
class TestCurtsiesPaintingTest(CurtsiesPaintingTest):
4661

4762
def test_history_is_cleared(self):
4863
self.assertEqual(self.repl.rl_history.entries, [''])
4964

5065

51-
class TestCurtsiesPaintingSimple(TestCurtsiesPainting):
66+
class TestCurtsiesPaintingSimple(CurtsiesPaintingTest):
5267

5368
def test_startup(self):
5469
screen = fsarray([cyan('>>> '), cyan('Welcome to')])
@@ -137,7 +152,7 @@ def output_to_repl(repl):
137152
sys.stdout, sys.stderr = old_out, old_err
138153

139154

140-
class TestCurtsiesRewindRedraw(TestCurtsiesPainting):
155+
class TestCurtsiesRewindRedraw(CurtsiesPaintingTest):
141156
def refresh(self):
142157
self.refresh_requests.append(RefreshRequestEvent())
143158

bpython/test/test_curtsies_repl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ def create_repl(**kwargs):
221221
config = setup_config({'editor': 'true'})
222222
repl = curtsiesrepl.Repl(config=config, **kwargs)
223223
os.environ['PAGER'] = 'true'
224+
os.environ.pop('PYTHONSTARTUP', None)
224225
repl.width = 50
225226
repl.height = 20
226227
return repl

0 commit comments

Comments
 (0)