Merge pull request #1519 from sontek/add_logging_to_prequest
Setup logging with prequest
| | |
| | | |
| | | from pyramid.compat import url_unquote |
| | | from pyramid.request import Request |
| | | from pyramid.paster import get_app |
| | | from pyramid.paster import get_app, setup_logging |
| | | from pyramid.scripts.common import parse_vars |
| | | |
| | | def main(argv=sys.argv, quiet=False): |
| | |
| | | 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] |
| | | path = self.args[1] |
| | | |
| | | self.configure_logging(app_spec) |
| | | |
| | | if not path.startswith('/'): |
| | | path = '/' + path |
| | | |
| | |
| | | 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 |