[damned-lies] Create a TestModuleBase class to setup testmodule as test module



commit d72a22643861b7dcca7cfb57ef842cecb4320da6
Author: Claude Paroz <claude 2xlibre net>
Date:   Mon Sep 17 13:18:21 2018 +0200

    Create a TestModuleBase class to setup testmodule as test module

 stats/tests/tests.py | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/stats/tests/tests.py b/stats/tests/tests.py
index 0ffd5357..2a930965 100644
--- a/stats/tests/tests.py
+++ b/stats/tests/tests.py
@@ -438,9 +438,10 @@ class ModuleTestCase(TestCase):
 
 
 @override_settings(SCRATCHDIR=str(Path(__file__).parent))
-class DomainTests(TestCase):
+class TestModuleBase(TestCase):
     @classmethod
     def setUpTestData(cls):
+        super().setUpTestData()
         Branch.checkout_on_creation = False
         Branch.checkout = mocked_checkout
         cls.mod = Module.objects.create(
@@ -450,6 +451,8 @@ class DomainTests(TestCase):
         cls.branch = Branch(module=cls.mod, name="master")
         cls.branch.save(update_statistics=False)
 
+
+class DomainTests(TestModuleBase):
     def setUp(self):
         super().setUp()
         Domain.doc_format.cache_clear()
@@ -730,16 +733,7 @@ class FigureTests(TestCase):
         self.assertTrue(errs[0][1].startswith("Figures should not be copied"))
 
 
-@override_settings(SCRATCHDIR=str(Path(__file__).parent))
-class UtilsTests(TestCase):
-    @classmethod
-    def setUpTestData(self):
-        Branch.checkout_on_creation = False
-        Branch.checkout = mocked_checkout
-        self.mod = Module.objects.create(name="testmodule", vcs_type='git')
-        self.branch = Branch(module=self.mod, name="master")
-        self.branch.save(update_statistics=False)
-
+class UtilsTests(TestModuleBase):
     def test_read_makefile_variable(self):
         domain = Domain.objects.create(
             module=self.mod, name='help', dtype='doc', layout='help_docbook/{lang}/{lang}.po'


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]