Add shared file tests to main test runner

This commit is contained in:
Kovid Goyal 2016-07-04 09:48:33 +05:30
parent 08d56e2eee
commit 253fd95479
2 changed files with 31 additions and 27 deletions

View File

@ -62,6 +62,8 @@ def find_tests(which_tests=None):
if ok('misc'):
from calibre.ebooks.metadata.tag_mapper import find_tests
a(find_tests())
from calibre.utils.shared_file import find_tests
a(find_tests())
tests = unittest.TestSuite(ans)
return tests

View File

@ -172,14 +172,15 @@ else:
def raise_winerror(x):
raise NotImplementedError(), None, sys.exc_info()[2]
def test():
import repr as reprlib
def eq(x, y):
if x != y:
raise AssertionError('%s != %s' % (reprlib.repr(x), reprlib.repr(y)))
def find_tests():
import unittest
from calibre.ptempfile import TemporaryDirectory
class SharedFileTest(unittest.TestCase):
def test_shared_file(self):
eq = self.assertEqual
with TemporaryDirectory() as tdir:
fname = os.path.join(tdir, 'test.txt')
with share_open(fname, 'wb') as f:
@ -201,3 +202,4 @@ def test():
f3 = share_open(fname, 'rb')
eq(f3.read(100), b'b' * 100)
return unittest.defaultTestLoader.loadTestsFromTestCase(SharedFileTest)