Define a base class for testing the objects

This commit is contained in:
Lee Miller 2024-10-11 09:06:45 +03:00
parent aa28ab37da
commit 2836f15d3c
Signed by: lee.miller
GPG Key ID: 4F97A5EA88F4AB63

View File

@ -19,19 +19,14 @@ from minode import sql, shared, structure
# + vectors_to_send # + vectors_to_send
class TestObjectsSQL(unittest.TestCase): class TestObjects():
"""A test case for the sqlite inventory""" """
A base class for the test case for shared.objects,
@classmethod containing tests for all the methods directly used in code.
def setUpClass(cls): """
shared.data_directory = tempfile.gettempdir() # pylint: disable=no-member
cls.tearDownClass() # A possibility of abstract test cases was rejected:
cls.objects = sql.Inventory() # https://bugs.python.org/issue17519
@classmethod
def tearDownClass(cls):
cls.objects = None
os.remove(os.path.join(shared.data_directory, 'objects.dat'))
def test_set_get(self): def test_set_get(self):
"""Put some objects and check presence and getting""" """Put some objects and check presence and getting"""
@ -151,3 +146,18 @@ class TestObjectsSQL(unittest.TestCase):
pending.add(obj.vector) pending.add(obj.vector)
self.assertEqual(self.objects.select(questionable), pending) 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'))