diff options
| author | John Anderson <sontek@gmail.com> | 2015-01-01 17:56:13 -0800 |
|---|---|---|
| committer | John Anderson <sontek@gmail.com> | 2015-01-01 17:56:13 -0800 |
| commit | aa9aef58b5b2fe4c9135aadc5481d129f1300154 (patch) | |
| tree | 5f0dfb74e36efeb38320e4eb9044a0c6a6f141b2 | |
| parent | 0882f7f0f4648b37617543a196ec4d5bf6d65278 (diff) | |
| download | pyramid-aa9aef58b5b2fe4c9135aadc5481d129f1300154.tar.gz pyramid-aa9aef58b5b2fe4c9135aadc5481d129f1300154.tar.bz2 pyramid-aa9aef58b5b2fe4c9135aadc5481d129f1300154.zip | |
Added a test for configuring logging
| -rw-r--r-- | pyramid/scripts/prequest.py | 7 | ||||
| -rw-r--r-- | pyramid/tests/test_scripts/test_prequest.py | 13 |
2 files changed, 19 insertions, 1 deletions
diff --git a/pyramid/scripts/prequest.py b/pyramid/scripts/prequest.py index 92faa146c..34eeadf32 100644 --- a/pyramid/scripts/prequest.py +++ b/pyramid/scripts/prequest.py @@ -97,13 +97,18 @@ class PRequestCommand(object): if not self.quiet: print(msg) + def configure_logging(self, app_spec): + setup_logging(app_spec) + def run(self): if not len(self.args) >= 2: self.out('You must provide at least two arguments') return 2 app_spec = self.args[0] - setup_logging(app_spec) path = self.args[1] + + self.configure_logging(app_spec) + if not path.startswith('/'): path = '/' + path diff --git a/pyramid/tests/test_scripts/test_prequest.py b/pyramid/tests/test_scripts/test_prequest.py index 37f1d3c0f..95cec0518 100644 --- a/pyramid/tests/test_scripts/test_prequest.py +++ b/pyramid/tests/test_scripts/test_prequest.py @@ -210,8 +210,21 @@ class TestPRequestCommand(unittest.TestCase): self.assertEqual(self._path_info, '/') self.assertEqual(self._spec, 'development.ini') self.assertEqual(self._app_name, None) + self.assertEqual(self._out, [b'abc']) + def test_command_method_configures_logging(self): + command = self._makeOne(['', 'development.ini', '/']) + called_args = [] + + def configure_logging(app_spec): + called_args.append(app_spec) + + command.configure_logging = configure_logging + command.run() + self.assertEqual(called_args, ['development.ini']) + + class Test_main(unittest.TestCase): def _callFUT(self, argv): from pyramid.scripts.prequest import main |
