| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 50d2b21 commit 3fb8441
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | 13 | from bpython.translations import init | |
| 14 | 14 | from bpython._py3compat import py3 | |
| 15 | + from six.moves import builtins | ||
| 15 | 16 | ||
| 16 | 17 | ||
| 17 | 18 | class FixLanguageTestCase(unittest.TestCase): | |
@@ -27,3 +28,8 @@ class MagicIterMock(mock.MagicMock): | |||
| 27 | 28 | __next__ = mock.Mock(return_value=None) | |
| 28 | 29 | else: | |
| 29 | 30 | next = mock.Mock(return_value=None) | |
| 31 | + | ||
| 32 | + | ||
| 33 | + def builtin_target(obj): | ||
| 34 | + """Returns mock target string of a builtin""" | ||
| 35 | + return '%s.%s' % (builtins.__name__, obj.__name__) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,11 +15,13 @@ | |||
| 15 | 15 | ||
| 16 | 16 | from bpython.curtsiesfrontend import repl as curtsiesrepl | |
| 17 | 17 | from bpython.curtsiesfrontend import interpreter | |
| 18 | + from bpython.curtsiesfrontend import events as bpythonevents | ||
| 18 | 19 | from bpython import autocomplete | |
| 19 | 20 | from bpython import config | |
| 20 | 21 | from bpython import args | |
| 21 | 22 | from bpython._py3compat import py3 | |
| 22 | - from bpython.test import FixLanguageTestCase as TestCase, MagicIterMock, mock | ||
| 23 | + from bpython.test import (FixLanguageTestCase as TestCase, MagicIterMock, mock, | ||
| 24 | + builtin_target) | ||
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | 27 | def setup_config(conf): | |
@@ -307,5 +309,20 @@ def test_show_source_formatted(self): | |||
| 307 | 309 | self.repl.show_source() | |
| 308 | 310 | ||
| 309 | 311 | ||
| 312 | + class TestCurtsiesStartup(TestCase): | ||
| 313 | + | ||
| 314 | + def setUp(self): | ||
| 315 | + self.repl = create_repl() | ||
| 316 | + os.environ['PYTHONSTARTUP'] = 'file' | ||
| 317 | + | ||
| 318 | + def tearDown(self): | ||
| 319 | + del os.environ['PYTHONSTARTUP'] | ||
| 320 | + | ||
| 321 | + @mock.patch(builtin_target(open), mock.mock_open(read_data='a = 1\n')) | ||
| 322 | + def test_startup_event(self): | ||
| 323 | + self.repl.process_event(bpythonevents.RunStartupFileEvent()) | ||
| 324 | + self.assertIn('a', self.repl.interp.locals) | ||
| 325 | + | ||
| 326 | + | ||
| 310 | 327 | if __name__ == '__main__': | |
| 311 | 328 | unittest.main() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments