mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add shared file tests to main test runner
This commit is contained in:
parent
08d56e2eee
commit
253fd95479
@ -62,6 +62,8 @@ def find_tests(which_tests=None):
|
|||||||
if ok('misc'):
|
if ok('misc'):
|
||||||
from calibre.ebooks.metadata.tag_mapper import find_tests
|
from calibre.ebooks.metadata.tag_mapper import find_tests
|
||||||
a(find_tests())
|
a(find_tests())
|
||||||
|
from calibre.utils.shared_file import find_tests
|
||||||
|
a(find_tests())
|
||||||
|
|
||||||
tests = unittest.TestSuite(ans)
|
tests = unittest.TestSuite(ans)
|
||||||
return tests
|
return tests
|
||||||
|
@ -172,14 +172,15 @@ else:
|
|||||||
def raise_winerror(x):
|
def raise_winerror(x):
|
||||||
raise NotImplementedError(), None, sys.exc_info()[2]
|
raise NotImplementedError(), None, sys.exc_info()[2]
|
||||||
|
|
||||||
def test():
|
def find_tests():
|
||||||
import repr as reprlib
|
import unittest
|
||||||
|
|
||||||
def eq(x, y):
|
|
||||||
if x != y:
|
|
||||||
raise AssertionError('%s != %s' % (reprlib.repr(x), reprlib.repr(y)))
|
|
||||||
|
|
||||||
from calibre.ptempfile import TemporaryDirectory
|
from calibre.ptempfile import TemporaryDirectory
|
||||||
|
|
||||||
|
class SharedFileTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_shared_file(self):
|
||||||
|
eq = self.assertEqual
|
||||||
|
|
||||||
with TemporaryDirectory() as tdir:
|
with TemporaryDirectory() as tdir:
|
||||||
fname = os.path.join(tdir, 'test.txt')
|
fname = os.path.join(tdir, 'test.txt')
|
||||||
with share_open(fname, 'wb') as f:
|
with share_open(fname, 'wb') as f:
|
||||||
@ -201,3 +202,4 @@ def test():
|
|||||||
f3 = share_open(fname, 'rb')
|
f3 = share_open(fname, 'rb')
|
||||||
eq(f3.read(100), b'b' * 100)
|
eq(f3.read(100), b'b' * 100)
|
||||||
|
|
||||||
|
return unittest.defaultTestLoader.loadTestsFromTestCase(SharedFileTest)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user