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
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'))