Skip to content

Commit

Permalink
Rewrite test without mock.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Feb 27, 2017
1 parent b2a749b commit 1702daa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
37 changes: 24 additions & 13 deletions pyramid/tests/test_scripts/test_pserve.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import mock
import os
import unittest
from pyramid.tests.test_scripts import dummy


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


Expand Down Expand Up @@ -81,18 +81,29 @@ def test_config_file_finds_watch_files(self):
])

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})
from pyramid.scripts import pserve

class AttrDict(dict):
def __init__(self, *args, **kwargs):
super(AttrDict, self).__init__(*args, **kwargs)
self.__dict__ = self

def dummy_start_reloader(*args, **kwargs):
dummy_start_reloader.args = args
dummy_start_reloader.kwargs = kwargs

pserve.hupper = AttrDict(is_active=lambda: False,
start_reloader=dummy_start_reloader)

inst = self._makeOne('--reload', 'development.ini')
inst.run()

self.assertEquals(dummy_start_reloader.args, ('pyramid.scripts.pserve.main',))
self.assertEquals(dummy_start_reloader.kwargs, {
'reload_interval': 1,
'verbose': 1,
'worker_kwargs': {'argv': ['pserve', '--reload', 'development.ini'],
'quiet': False}})


class Test_main(unittest.TestCase):
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
]

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

0 comments on commit 1702daa

Please sign in to comment.