Skip to content

Commit

Permalink
Mock objects never had an assert_called_once()
Browse files Browse the repository at this point in the history
There's an assert_called_once_with(), but it checks all the arguments.

Luckily, new mock releases (starting with 1.1.0) don't let me call
random do-nothing assert_foo() methods.
  • Loading branch information
mgedmin committed Jul 13, 2015
1 parent 2c4e906 commit 4ea97eb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/restview/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def test_serve(self):
viewer = RestViewer('.')
viewer.server = Mock()
viewer.serve()
viewer.server.serve_forever.assert_called_once()
self.assertEqual(viewer.server.serve_forever.call_count, 1)


class TestGlobals(unittest.TestCase):
Expand All @@ -763,7 +763,7 @@ def test_launch_browser(self):
Thread.assert_called_once_with(target=webbrowser.open,
args=('http://example.com',))
Thread.return_value.setDaemon.assert_called_once_with(True)
Thread.return_value.start.assert_called_once()
self.assertEqual(Thread.return_value.start.call_count, 1)


class TestMain(unittest.TestCase):
Expand Down Expand Up @@ -795,7 +795,7 @@ def run_main(self, *args, **kw):
if serve_called:
self.assertTrue(self._serve_called)
if browser_launched:
launch_browser.assert_called_once()
self.assertEqual(launch_browser.call_count, 1)
return stdout.getvalue(), stderr.getvalue()

def test_help(self):
Expand Down

3 comments on commit 4ea97eb

@domenkozar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to have a release out with these fixes :)

@mgedmin
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the interest!

restview 2.5.0 is out on PyPI now.

@domenkozar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍻

Please sign in to comment.