forked from nipy/nibabel
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NF+TEST - fix to substitution with start of testing
- Loading branch information
1 parent
5ff05b0
commit b04fe7c
Showing
4 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Tests for nisext package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" Tests for nisexts.sexts module | ||
""" | ||
|
||
import sys | ||
import imp | ||
|
||
from ..sexts import package_check | ||
|
||
from nose.tools import assert_true, assert_false, assert_equal, assert_raises | ||
|
||
FAKE_NAME = 'nisext_improbable' | ||
assert FAKE_NAME not in sys.modules | ||
FAKE_MODULE = imp.new_module('nisext_fake') | ||
|
||
|
||
def test_package_check(): | ||
# Try to use a required package - raise error | ||
assert_raises(RuntimeError, package_check, FAKE_NAME) | ||
# Optional, log.warn | ||
package_check(FAKE_NAME, optional=True) | ||
# Make a package | ||
sys.modules[FAKE_NAME] = FAKE_MODULE | ||
# Now it passes if we don't check the version | ||
package_check(FAKE_NAME) | ||
# A fake version | ||
FAKE_MODULE.__version__ = '0.2' | ||
package_check(FAKE_NAME, version='0.2') | ||
# fails when version not good enough | ||
assert_raises(RuntimeError, package_check, FAKE_NAME, '0.3') | ||
# Unless optional in which case log.warns | ||
package_check(FAKE_NAME, version='0.3', optional=True) | ||
# Might do custom version check | ||
package_check(FAKE_NAME, version='0.2', version_getter=lambda x: '0.2') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters