From 2836f15d3c67e31edc0a858430a5bce308988d8a Mon Sep 17 00:00:00 2001 From: Lee Miller Date: Fri, 11 Oct 2024 09:06:45 +0300 Subject: [PATCH] Define a base class for testing the objects --- minode/tests/test_objects.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/minode/tests/test_objects.py b/minode/tests/test_objects.py index 46bff6c..22ecd07 100644 --- a/minode/tests/test_objects.py +++ b/minode/tests/test_objects.py @@ -19,19 +19,14 @@ from minode import sql, shared, structure # + vectors_to_send -class TestObjectsSQL(unittest.TestCase): - """A test case for the sqlite inventory""" - - @classmethod - def setUpClass(cls): - shared.data_directory = tempfile.gettempdir() - cls.tearDownClass() - cls.objects = sql.Inventory() - - @classmethod - def tearDownClass(cls): - cls.objects = None - os.remove(os.path.join(shared.data_directory, 'objects.dat')) +class TestObjects(): + """ + A base class for the test case for shared.objects, + containing tests for all the methods directly used in code. + """ + # pylint: disable=no-member + # A possibility of abstract test cases was rejected: + # https://bugs.python.org/issue17519 def test_set_get(self): """Put some objects and check presence and getting""" @@ -151,3 +146,18 @@ class TestObjectsSQL(unittest.TestCase): pending.add(obj.vector) self.assertEqual(self.objects.select(questionable), pending) + + +class TestObjectsSQL(TestObjects, unittest.TestCase): + """A test case for the sqlite inventory""" + + @classmethod + def setUpClass(cls): + shared.data_directory = tempfile.gettempdir() + cls.tearDownClass() + cls.objects = sql.Inventory() + + @classmethod + def tearDownClass(cls): + cls.objects = None + os.remove(os.path.join(shared.data_directory, 'objects.dat'))