Permalink
Browse files

fix unittests in wiki2 to work without deps on py2 and py3

fixes #2882
  • Loading branch information...
1 parent 041769e commit fb7a98bbdacebc4edfef8fb3e6093bb9e6590111 @mmerickel mmerickel committed Jan 10, 2017
@@ -1,20 +1,16 @@
-import mock
+import os
import unittest
class TestInitializeDB(unittest.TestCase):
- @mock.patch('tutorial.scripts.initializedb.sys')
- def test_usage(self, mocked_sys):
+ def test_usage(self):
from ..scripts.initializedb import main
- main(argv=['foo'])
- mocked_sys.exit.assert_called_with(1)
+ with self.assertRaises(SystemExit):
+ main(argv=['foo'])
- @mock.patch('tutorial.scripts.initializedb.get_tm_session')
- @mock.patch('tutorial.scripts.initializedb.sys')
- def test_run(self, mocked_sys, mocked_session):
+ def test_run(self):
from ..scripts.initializedb import main
main(argv=['foo', 'development.ini'])
- mocked_session.assert_called_once()
-
-
+ self.assertTrue(os.path.exists('tutorial.sqlite'))
+ os.remove('tutorial.sqlite')
@@ -1,19 +1,21 @@
-import mock
import unittest
+from pyramid.testing import DummyRequest
class TestMyAuthenticationPolicy(unittest.TestCase):
def test_no_user(self):
- request = mock.Mock()
+ request = DummyRequest()
request.user = None
from ..security import MyAuthenticationPolicy
policy = MyAuthenticationPolicy(None)
self.assertEqual(policy.authenticated_userid(request), None)
def test_authenticated_user(self):
- request = mock.Mock()
+ from ..models import User
+ request = DummyRequest()
+ request.user = User()
request.user.id = 'foo'
from ..security import MyAuthenticationPolicy

0 comments on commit fb7a98b

Please sign in to comment.