Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Feb 20, 2017
1 parent d64e8d1 commit b2a749b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion pyramid/tests/test_scripts/test_pserve.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import mock
import os
import unittest
from pyramid.tests.test_scripts import dummy

here = os.path.abspath(os.path.dirname(__file__))


class TestPServeCommand(unittest.TestCase):
def setUp(self):
from pyramid.compat import NativeIO
Expand Down Expand Up @@ -48,10 +50,11 @@ def test_parse_vars_good(self):
inst.loadserver = self._get_server

app = dummy.DummyApp()

def get_app(*args, **kwargs):
app.global_conf = kwargs.get('global_conf', None)
inst.loadapp = get_app

inst.loadapp = get_app
inst.run()
self.assertEqual(app.global_conf, {'a': '1', 'b': '2'})

Expand All @@ -77,6 +80,21 @@ def test_config_file_finds_watch_files(self):
os.path.abspath(os.path.join(here, '*.py')),
])

def test_reload_call_hupper_with_correct_args(self):
with mock.patch('pyramid.scripts.pserve.hupper') as hupper_mock:
hupper_mock.is_active.side_effect = [False, True]
inst = self._makeOne('--reload', 'development.ini')
inst.loadserver = mock.MagicMock()
inst.loadapp = mock.MagicMock()
inst.run()
hupper_mock.start_reloader.assert_called_with(
'pyramid.scripts.pserve.main',
reload_interval=1,
verbose=1,
worker_kwargs={'argv': ['pserve', '--reload', 'development.ini'],
'quiet': False})


class Test_main(unittest.TestCase):
def _callFUT(self, argv):
from pyramid.scripts.pserve import main
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@
]

testing_extras = tests_require + [
'mock',
'nose',
'coverage',
'virtualenv', # for scaffolding tests
'virtualenv', # for scaffolding tests
]

setup(name='pyramid',
Expand Down

0 comments on commit b2a749b

Please sign in to comment.