|
1 | | -from importlib import import_module |
| 1 | +import importlib |
2 | 2 | from ..info import cmp_pkg_version |
3 | | -from ..testing import assert_raises |
| 3 | +from ..testing import assert_raises, assert_false |
4 | 4 |
|
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')]), |
7 | 16 | ] |
8 | 17 |
|
9 | 18 |
|
10 | | -def test_removals(): |
11 | | - for version, to_remove in SCHEDULE: |
| 19 | +def test_module_removal(): |
| 20 | + for version, to_remove in MODULE_SCHEDULE: |
12 | 21 | if cmp_pkg_version(version) < 1: |
13 | 22 | for module in to_remove: |
14 | 23 | 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