diff options
| author | Chris McDonough <chrism@agendaless.com> | 2009-10-19 18:43:01 +0000 |
|---|---|---|
| committer | Chris McDonough <chrism@agendaless.com> | 2009-10-19 18:43:01 +0000 |
| commit | b3e9ee1f5863cbe0d092f29e25cb4363d7398b64 (patch) | |
| tree | b6798fb91ac73a366b6435ab0c8ca70e8a25772f /repoze/bfg/tests | |
| parent | d5b2f46f323571ec32fa7e9c77ccf83f62a03fea (diff) | |
| download | pyramid-b3e9ee1f5863cbe0d092f29e25cb4363d7398b64.tar.gz pyramid-b3e9ee1f5863cbe0d092f29e25cb4363d7398b64.tar.bz2 pyramid-b3e9ee1f5863cbe0d092f29e25cb4363d7398b64.zip | |
- ``paster bfgshell`` now supports IPython if it's available for
import. Thanks to Daniel Holth for the initial patch.
Diffstat (limited to 'repoze/bfg/tests')
| -rw-r--r-- | repoze/bfg/tests/test_paster.py | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/repoze/bfg/tests/test_paster.py b/repoze/bfg/tests/test_paster.py index 0119e3313..4650f04cd 100644 --- a/repoze/bfg/tests/test_paster.py +++ b/repoze/bfg/tests/test_paster.py @@ -8,14 +8,18 @@ class TestBFGShellCommand(unittest.TestCase): def _makeOne(self): return self._getTargetClass()('bfgshell') - def test_command(self): + def test_command_ipython_disabled(self): command = self._makeOne() interact = DummyInteractor() app = DummyApp() loadapp = DummyLoadApp(app) command.interact = (interact,) command.loadapp = (loadapp,) + command.IPShellEmbed = True # fake out command.args = ('/foo/bar/myapp.ini', 'myapp') + class Options(object): pass + command.options = Options() + command.options.disable_ipython =True command.command() self.assertEqual(loadapp.config_name, 'config:/foo/bar/myapp.ini') self.assertEqual(loadapp.section_name, 'myapp') @@ -28,6 +32,31 @@ class TestBFGShellCommand(unittest.TestCase): self.failUnless(interact.banner) self.assertEqual(len(app.threadlocal_manager.popped), 1) + def test_command_ipython_enabled(self): + command = self._makeOne() + interact = DummyInteractor() + app = DummyApp() + loadapp = DummyLoadApp(app) + command.loadapp = (loadapp,) + dummy_shell_factory = DummyIPShellFactory() + command.IPShellEmbed = dummy_shell_factory + command.args = ('/foo/bar/myapp.ini', 'myapp') + class Options(object): pass + command.options = Options() + command.options.disable_ipython = False + command.command() + self.assertEqual(loadapp.config_name, 'config:/foo/bar/myapp.ini') + self.assertEqual(loadapp.section_name, 'myapp') + self.failUnless(loadapp.relative_to) + self.assertEqual(len(app.threadlocal_manager.pushed), 1) + pushed = app.threadlocal_manager.pushed[0] + self.assertEqual(pushed['registry'], dummy_registry) + self.assertEqual(pushed['request'], None) + self.assertEqual(dummy_shell_factory.shell.local_ns,{'root':dummy_root}) + self.assertEqual(dummy_shell_factory.shell.global_ns, {}) + self.failUnless(dummy_shell_factory.shell.banner) + self.assertEqual(len(app.threadlocal_manager.popped), 1) + class TestGetApp(unittest.TestCase): def _callFUT(self, config_file, section_name, loadapp): from repoze.bfg.paster import get_app @@ -46,6 +75,22 @@ class TestGetApp(unittest.TestCase): class Dummy: pass +class DummyIPShellFactory(object): + def __call__(self, argv): + shell = DummyIPShell() + self.shell = shell + return shell + +class DummyIPShell(object): + IP = Dummy() + IP.BANNER = 'foo' + def set_banner(self, banner): + self.banner = banner + + def __call__(self, local_ns, global_ns): + self.local_ns = local_ns + self.global_ns = global_ns + dummy_root = Dummy() dummy_registry = Dummy() |
