Skip to content

Commit 4746a1c

Browse files
committed
TEST: Verify ImportError, add object removal schedule, schedul trackvis removal
1 parent 3c8ca39 commit 4746a1c

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed
Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
1-
from importlib import import_module
1+
import importlib
22
from ..info import cmp_pkg_version
3-
from ..testing import assert_raises
3+
from ..testing import assert_raises, assert_false
44

5-
SCHEDULE = [
6-
('3.0.0', ('nibabel.minc', 'nibabel.checkwarns')),
5+
MODULE_SCHEDULE = [
6+
('4.0.0', ['nibabel.trackvis']),
7+
('3.0.0', ['nibabel.minc', 'nibabel.checkwarns']),
8+
# Verify that the test will be quiet if the schedule outlives the modules
9+
('1.0.0', ['nibabel.neverexisted']),
10+
]
11+
12+
OBJECT_SCHEDULE = [
13+
('3.0.0', [('nibabel.testing', 'catch_warn_reset')]),
14+
# Verify that the test will be quiet if the schedule outlives the modules
15+
('1.0.0', [('nibabel', 'neverexisted')]),
716
]
817

918

10-
def test_removals():
11-
for version, to_remove in SCHEDULE:
19+
def test_module_removal():
20+
for version, to_remove in MODULE_SCHEDULE:
1221
if cmp_pkg_version(version) < 1:
1322
for module in to_remove:
1423
with assert_raises(ImportError, msg="Time to remove " + module):
15-
import_module(module)
24+
importlib.__import__(module)
25+
26+
27+
def test_object_removal():
28+
for version, to_remove in OBJECT_SCHEDULE:
29+
if cmp_pkg_version(version) < 1:
30+
for module_name, obj in to_remove:
31+
try:
32+
module = importlib.__import__(module_name)
33+
except ImportError:
34+
continue
35+
assert_false(hasattr(module, obj), msg="Time to remove %s.%s" % (module_name, obj))

0 commit comments

Comments
 (0)