Commit b42cb77a authored by Tres Seaver's avatar Tres Seaver

Refactor legacy tests to cover both C and Python implementations.

parent dbecf225
...@@ -15,19 +15,19 @@ import unittest ...@@ -15,19 +15,19 @@ import unittest
Picklable = None # avoid global import of Persistent; updated later Picklable = None # avoid global import of Persistent; updated later
class PersistenceTest(unittest.TestCase): class _Base(object):
def _makeOne(self): def _makeOne(self):
from persistent import Persistent class P(self._getTargetClass()):
class P(Persistent):
pass pass
return P() return P()
def _makeJar(self): def _makeJar(self):
from persistent.tests.utils import ResettingJar from persistent.tests.utils import ResettingJar
return ResettingJar() jar = ResettingJar()
jar.cache = jar._cache = self._makeCache(jar)
return jar
def test_oid_initial_value(self): def test_oid_initial_value(self):
obj = self._makeOne() obj = self._makeOne()
...@@ -316,6 +316,36 @@ class PersistenceTest(unittest.TestCase): ...@@ -316,6 +316,36 @@ class PersistenceTest(unittest.TestCase):
# TODO: Need to decide how __setattr__ and __delattr__ should work, # TODO: Need to decide how __setattr__ and __delattr__ should work,
# then write tests. # then write tests.
class PythonPersistentTests(unittest.TestCase, _Base):
def _getTargetClass(self):
from persistent.persistence import Persistent
return Persistent
def _makeCache(self, jar):
from persistent.picklecache import PickleCache
return PickleCache(jar)
_add_to_suite = [PythonPersistentTests]
try:
import persistent.cPersistence
except ImportError:
pass
else:
class CPersistentTests(unittest.TestCase, _Base):
def _getTargetClass(self):
from persistent.cPersistence import Persistent
return Persistent
def _makeCache(self, jar):
from persistent.cPickleCache import PickleCache
return PickleCache(jar)
_add_to_suite.append(CPersistentTests)
def test_suite(): def test_suite():
return unittest.makeSuite(PersistenceTest) return unittest.TestSuite((
[unittest.makeSuite(x) for x in _add_to_suite]
))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment