From 6007dd9a6a22e1112afa6a72ca2ee406698d775f Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Tue, 16 Aug 2011 03:09:34 -0500 Subject: Added tests for module without __all__. --- pyramid/tests/pshellapp/__init__.py | 7 ------- pyramid/tests/pshellapp/no_all.py | 5 +++++ pyramid/tests/pshellapp/with_all.py | 7 +++++++ pyramid/tests/test_paster.py | 33 +++++++++++++++++++++++++++------ 4 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 pyramid/tests/pshellapp/no_all.py create mode 100644 pyramid/tests/pshellapp/with_all.py diff --git a/pyramid/tests/pshellapp/__init__.py b/pyramid/tests/pshellapp/__init__.py index dd0a3e2f9..e69de29bb 100644 --- a/pyramid/tests/pshellapp/__init__.py +++ b/pyramid/tests/pshellapp/__init__.py @@ -1,7 +0,0 @@ -__all__ = ['a', 'root', 'm'] - -a = 1 -b = 2 - -root = 'root override' -m = 'model override' diff --git a/pyramid/tests/pshellapp/no_all.py b/pyramid/tests/pshellapp/no_all.py new file mode 100644 index 000000000..177a34590 --- /dev/null +++ b/pyramid/tests/pshellapp/no_all.py @@ -0,0 +1,5 @@ +a = 1 +b = 2 + +root = 'root override' +m = 'model override' diff --git a/pyramid/tests/pshellapp/with_all.py b/pyramid/tests/pshellapp/with_all.py new file mode 100644 index 000000000..dd0a3e2f9 --- /dev/null +++ b/pyramid/tests/pshellapp/with_all.py @@ -0,0 +1,7 @@ +__all__ = ['a', 'root', 'm'] + +a = 1 +b = 2 + +root = 'root override' +m = 'model override' diff --git a/pyramid/tests/test_paster.py b/pyramid/tests/test_paster.py index cb30dcc12..49a54aecc 100644 --- a/pyramid/tests/test_paster.py +++ b/pyramid/tests/test_paster.py @@ -157,9 +157,10 @@ class TestPShellCommand(unittest.TestCase): self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.help) - def test_command_loads_use_script(self): + def test_command_loads_use_script_with_all(self): command = self._makeOne() - self.config_factory.items = [('import', 'pyramid.tests.pshellapp')] + self.config_factory.items = [ + ('import', 'pyramid.tests.pshellapp.with_all')] shell = DummyShell() command.command(shell) self.assertTrue(self.config_factory.parser) @@ -176,11 +177,31 @@ class TestPShellCommand(unittest.TestCase): self.assertTrue(self.bootstrap.closer.called) self.assertTrue(shell.help) - def test_command_loads_use_script_check_order(self): + def test_command_loads_use_script_without_all(self): + command = self._makeOne() + self.config_factory.items = [ + ('import', 'pyramid.tests.pshellapp.no_all')] + shell = DummyShell() + command.command(shell) + self.assertTrue(self.config_factory.parser) + self.assertEqual(self.config_factory.parser.filename, + '/foo/bar/myapp.ini') + self.assertEqual(self.bootstrap.a[0], '/foo/bar/myapp.ini#myapp') + self.assertEqual(shell.env, { + 'app':self.bootstrap.app, 'root':'root override', + 'registry':self.bootstrap.registry, + 'request':self.bootstrap.request, + 'root_factory':self.bootstrap.root_factory, + 'a': 1, 'b': 2, 'm': 'model override', + }) + self.assertTrue(self.bootstrap.closer.called) + self.assertTrue(shell.help) + + def test_command_loads_check_variable_override_order(self): command = self._makeOne() model = Dummy() - self.config_factory.items = [('import', 'pyramid.tests.pshellapp'), - ('m', model)] + self.config_factory.items = [ + ('import', 'pyramid.tests.pshellapp.with_all'), ('m', model)] shell = DummyShell() command.command(shell) self.assertTrue(self.config_factory.parser) @@ -202,7 +223,7 @@ class TestPShellCommand(unittest.TestCase): model = Dummy() self.config_factory.items = [('import', 'abc'), ('m', model)] - command.options.use_script = 'pyramid.tests.pshellapp' + command.options.use_script = 'pyramid.tests.pshellapp.with_all' shell = DummyShell() command.command(shell) self.assertTrue(self.config_factory.parser) -- cgit v1.2.3