changeset 5801:15c40f8a3510

pytest migration: convert functional tests with setup/teardown methods pytest also supports setup/teardown methods like unittest (even though pytest fixtures are more powerful and should be the end goal). Only difference is the naming and signature of setUp (setup_method) and tearDown (teardown_method).
author Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
date Tue, 26 Apr 2016 17:35:13 +0200
parents 44835b81c956
children 1173317b4f1a
files kallithea/tests/functional/test_admin.py kallithea/tests/functional/test_admin_gists.py kallithea/tests/functional/test_admin_notifications.py kallithea/tests/functional/test_admin_repos.py kallithea/tests/functional/test_changeset_comments.py kallithea/tests/functional/test_compare.py kallithea/tests/functional/test_forks.py kallithea/tests/functional/test_pullrequests.py
diffstat 8 files changed, 20 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/tests/functional/test_admin.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_admin.py	Tue Apr 26 17:35:13 2016 +0200
@@ -10,7 +10,7 @@
 FIXTURES = os.path.join(dn(dn(os.path.abspath(__file__))), 'fixtures')
 
 
-class TestAdminController(TestController):
+class TestAdminController(TestControllerPytest):
 
     @classmethod
     def setup_class(cls):
--- a/kallithea/tests/functional/test_admin_gists.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_admin_gists.py	Tue Apr 26 17:35:13 2016 +0200
@@ -18,9 +18,9 @@
     return gist
 
 
-class TestGistsController(TestController):
+class TestGistsController(TestControllerPytest):
 
-    def tearDown(self):
+    def teardown_method(self, method):
         for g in Gist.get_all():
             GistModel().delete(g)
         Session().commit()
--- a/kallithea/tests/functional/test_admin_notifications.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_admin_notifications.py	Tue Apr 26 17:35:13 2016 +0200
@@ -7,8 +7,8 @@
 from kallithea.lib import helpers as h
 
 
-class TestNotificationsController(TestController):
-    def setUp(self):
+class TestNotificationsController(TestControllerPytest):
+    def setup_method(self, method):
         remove_all_notifications()
 
     def test_index(self):
--- a/kallithea/tests/functional/test_admin_repos.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_admin_repos.py	Tue Apr 26 17:35:13 2016 +0200
@@ -604,7 +604,7 @@
         # repo must not be in filesystem !
         self.assertFalse(os.path.isdir(os.path.join(Ui.get_by_key('paths', '/').ui_value, repo_name)))
 
-class TestAdminReposControllerGIT(TestController, _BaseTest):
+class TestAdminReposControllerGIT(TestControllerPytest, _BaseTest):
     REPO = GIT_REPO
     REPO_TYPE = 'git'
     NEW_REPO = NEW_GIT_REPO
@@ -612,7 +612,7 @@
     OTHER_TYPE = 'hg'
 
 
-class TestAdminReposControllerHG(TestController, _BaseTest):
+class TestAdminReposControllerHG(TestControllerPytest, _BaseTest):
     REPO = HG_REPO
     REPO_TYPE = 'hg'
     NEW_REPO = NEW_HG_REPO
--- a/kallithea/tests/functional/test_changeset_comments.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_changeset_comments.py	Tue Apr 26 17:35:13 2016 +0200
@@ -4,9 +4,9 @@
 from kallithea.model.meta import Session
 
 
-class TestChangeSetCommentsController(TestController):
+class TestChangeSetCommentsController(TestControllerPytest):
 
-    def setUp(self):
+    def setup_method(self, method):
         for x in ChangesetComment.query().all():
             Session().delete(x)
         Session().commit()
--- a/kallithea/tests/functional/test_compare.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_compare.py	Tue Apr 26 17:35:13 2016 +0200
@@ -10,13 +10,13 @@
     return """<div id="C-%s" class="message">%s</div>""" % (sha, msg)
 
 
-class TestCompareController(TestController):
+class TestCompareController(TestControllerPytest):
 
-    def setUp(self):
+    def setup_method(self, method):
         self.r1_id = None
         self.r2_id = None
 
-    def tearDown(self):
+    def teardown_method(self, method):
         if self.r2_id:
             RepoModel().delete(self.r2_id)
         if self.r1_id:
--- a/kallithea/tests/functional/test_forks.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_forks.py	Tue Apr 26 17:35:13 2016 +0200
@@ -12,10 +12,7 @@
 
 fixture = Fixture()
 
-from kallithea.tests import *
-
-
-class _BaseFixture(unittest.TestCase):
+class _BaseFixture(object):
     @classmethod
     def setup_class(cls):
         pass
@@ -24,14 +21,14 @@
     def teardown_class(cls):
         pass
 
-    def setUp(self):
+    def setup_method(self, method):
         self.username = u'forkuser'
         self.password = u'qweqwe'
         self.u1 = fixture.create_user(self.username, password=self.password,
                                       email=u'fork_king@example.com')
         Session().commit()
 
-    def tearDown(self):
+    def teardown_method(self, method):
         Session().delete(self.u1)
         Session().commit()
 
@@ -224,14 +221,14 @@
         response.mustcontain('There are no forks yet')
 
 
-class TestGIT(TestController, _BaseTestCase, _BaseFixture):
+class TestGIT(TestControllerPytest, _BaseTestCase, _BaseFixture):
     REPO = GIT_REPO
     NEW_REPO = NEW_GIT_REPO
     REPO_TYPE = 'git'
     REPO_FORK = GIT_FORK
 
 
-class TestHG(TestController, _BaseTestCase, _BaseFixture):
+class TestHG(TestControllerPytest, _BaseTestCase, _BaseFixture):
     REPO = HG_REPO
     NEW_REPO = NEW_HG_REPO
     REPO_TYPE = 'hg'
--- a/kallithea/tests/functional/test_pullrequests.py	Fri Mar 11 22:20:04 2016 +0100
+++ b/kallithea/tests/functional/test_pullrequests.py	Tue Apr 26 17:35:13 2016 +0200
@@ -143,15 +143,15 @@
                                  status=400)
         response.mustcontain('Invalid reviewer &#34;%s&#34; specified' % invalid_user_id)
 
-class TestPullrequestsGetRepoRefs(TestController):
+class TestPullrequestsGetRepoRefs(TestControllerPytest):
 
-    def setUp(self):
+    def setup_method(self, method):
         self.main = fixture.create_repo(u'main', repo_type='hg')
         Session.add(self.main)
         Session.commit()
         self.c = PullrequestsController()
 
-    def tearDown(self):
+    def teardown_method(self, method):
         fixture.destroy_repo(u'main')
         Session.commit()
         Session.remove()