Skip to content

Commit

Permalink
Added tests for module without __all__.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerickel committed Aug 16, 2011
1 parent 8a455db commit 6007dd9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
7 changes: 0 additions & 7 deletions pyramid/tests/pshellapp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
__all__ = ['a', 'root', 'm']

a = 1
b = 2

root = 'root override'
m = 'model override'
5 changes: 5 additions & 0 deletions pyramid/tests/pshellapp/no_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a = 1
b = 2

root = 'root override'
m = 'model override'
7 changes: 7 additions & 0 deletions pyramid/tests/pshellapp/with_all.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
__all__ = ['a', 'root', 'm']

a = 1
b = 2

root = 'root override'
m = 'model override'
33 changes: 27 additions & 6 deletions pyramid/tests/test_paster.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ def test_command_loads_custom_items(self):
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)
Expand All @@ -176,11 +177,31 @@ def test_command_loads_use_script(self):
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)
Expand All @@ -202,7 +223,7 @@ def test_command_loads_use_script_override(self):
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)
Expand Down

0 comments on commit 6007dd9

Please sign in to comment.