mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
test: try to make test_import work better without assuming cwd
Allows it to run properly on Windows.
This commit is contained in:
parent
a75b0730a7
commit
02be4edee2
@ -82,7 +82,9 @@ class BuildTest(unittest.TestCase):
|
|||||||
exclude.append('osx')
|
exclude.append('osx')
|
||||||
if not islinux:
|
if not islinux:
|
||||||
exclude.extend(['dbus', 'linux'])
|
exclude.extend(['dbus', 'linux'])
|
||||||
for root, dirs, files in os.walk('src/calibre'):
|
base = os.path.dirname(__file__)
|
||||||
|
trimpath = len(os.path.dirname(base)) + 1
|
||||||
|
for root, dirs, files in os.walk(base):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
if not os.path.isfile(os.path.join(root, dir, '__init__.py')):
|
if not os.path.isfile(os.path.join(root, dir, '__init__.py')):
|
||||||
dirs.remove(dir)
|
dirs.remove(dir)
|
||||||
@ -90,7 +92,7 @@ class BuildTest(unittest.TestCase):
|
|||||||
file, ext = os.path.splitext(file)
|
file, ext = os.path.splitext(file)
|
||||||
if ext != '.py':
|
if ext != '.py':
|
||||||
continue
|
continue
|
||||||
name = '.'.join(root.split(os.path.sep)[1:] + [file])
|
name = '.'.join(root[trimpath:].split(os.path.sep) + [file])
|
||||||
if not any(x for x in exclude if x in name):
|
if not any(x for x in exclude if x in name):
|
||||||
importlib.import_module(name)
|
importlib.import_module(name)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user