File purge-nose.patch of Package python-nibabel
Index: nibabel-3.1.1/nisext/tests/test_sexts.py
===================================================================
--- nibabel-3.1.1.orig/nisext/tests/test_sexts.py
+++ nibabel-3.1.1/nisext/tests/test_sexts.py
@@ -6,7 +6,7 @@ import types
from ..sexts import package_check
-from nose.tools import assert_true, assert_false, assert_equal, assert_raises
+import pytest
FAKE_NAME = 'nisext_improbable'
assert FAKE_NAME not in sys.modules
@@ -15,7 +15,8 @@ FAKE_MODULE = types.ModuleType('nisext_f
def test_package_check():
# Try to use a required package - raise error
- assert_raises(RuntimeError, package_check, FAKE_NAME)
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME)
# Optional, log.warn
package_check(FAKE_NAME, optional=True)
# Can also pass a string
@@ -29,7 +30,8 @@ def test_package_check():
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')
+ with pytest.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
@@ -40,78 +42,63 @@ def test_package_check():
def test_package_check_setuptools():
# If setuptools arg not None, missing package just adds it to arg
- assert_raises(RuntimeError, package_check, FAKE_NAME, setuptools_args=None)
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME, setuptools_args=None)
def pkg_chk_sta(*args, **kwargs):
st_args = {}
package_check(*args, setuptools_args=st_args, **kwargs)
return st_args
- assert_equal(pkg_chk_sta(FAKE_NAME),
- {'install_requires': ['nisext_improbable']})
+ assert pkg_chk_sta(FAKE_NAME) == {'install_requires': ['nisext_improbable']}
# Check that this gets appended to existing value
old_sta = {'install_requires': ['something']}
package_check(FAKE_NAME, setuptools_args=old_sta)
- assert_equal(old_sta,
- {'install_requires': ['something', 'nisext_improbable']})
+ assert old_sta == {'install_requires': ['something', 'nisext_improbable']}
# That existing value as string gets converted to a list
old_sta = {'install_requires': 'something'}
package_check(FAKE_NAME, setuptools_args=old_sta)
- assert_equal(old_sta,
- {'install_requires': ['something', 'nisext_improbable']})
+ assert old_sta == {'install_requires': ['something', 'nisext_improbable']}
# Optional, add to extras_require
- assert_equal(pkg_chk_sta(FAKE_NAME, optional='something'),
- {'extras_require': {'something': ['nisext_improbable']}})
+ assert pkg_chk_sta(FAKE_NAME, optional='something') == {'extras_require': {'something': ['nisext_improbable']}}
# Check that this gets appended to existing value
old_sta = {'extras_require': {'something': ['amodule']}}
package_check(FAKE_NAME, optional='something', setuptools_args=old_sta)
- assert_equal(old_sta,
- {'extras_require':
- {'something': ['amodule', 'nisext_improbable']}})
+ assert old_sta == {'extras_require': {'something': ['amodule', 'nisext_improbable']}}
# That string gets converted to a list here too
old_sta = {'extras_require': {'something': 'amodule'}}
package_check(FAKE_NAME, optional='something', setuptools_args=old_sta)
- assert_equal(old_sta,
- {'extras_require':
- {'something': ['amodule', 'nisext_improbable']}})
+ assert old_sta == {'extras_require':
+ {'something': ['amodule', 'nisext_improbable']}}
# But optional has to be a string if not empty and setuptools_args defined
- assert_raises(RuntimeError,
- package_check, FAKE_NAME, optional=True, setuptools_args={})
+ with pytest.raises(RuntimeError):
+ package_check(FAKE_NAME, optional=True, setuptools_args={})
try:
# Make a package
sys.modules[FAKE_NAME] = FAKE_MODULE
# No install_requires because we already have it
- assert_equal(pkg_chk_sta(FAKE_NAME), {})
+ assert pkg_chk_sta(FAKE_NAME) == {}
# A fake version still works
FAKE_MODULE.__version__ = '0.2'
- assert_equal(pkg_chk_sta(FAKE_NAME, version='0.2'), {})
+ assert pkg_chk_sta(FAKE_NAME, version='0.2') == {}
# goes into install requires when version not good enough
exp_spec = [FAKE_NAME + '>=0.3']
- assert_equal(pkg_chk_sta(FAKE_NAME, version='0.3'),
- {'install_requires': exp_spec})
+ assert pkg_chk_sta(FAKE_NAME, version='0.3') == {'install_requires': exp_spec}
# Unless optional in which case goes into extras_require
package_check(FAKE_NAME, version='0.2', version_getter=lambda x: '0.2')
- assert_equal(
- pkg_chk_sta(FAKE_NAME, version='0.3', optional='afeature'),
- {'extras_require': {'afeature': exp_spec}})
+ assert pkg_chk_sta(FAKE_NAME, version='0.3', optional='afeature') == {'extras_require': {'afeature': exp_spec}}
# Might do custom version check
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
- version_getter=lambda x: '0.2'),
- {})
+ version_getter=lambda x: '0.2') == {}
# If the version check fails, put into requires
bad_getter = lambda x: x.not_an_attribute
exp_spec = [FAKE_NAME + '>=0.2']
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
- version_getter=bad_getter),
- {'install_requires': exp_spec})
+ version_getter=bad_getter) == {'install_requires': exp_spec}
# Likewise for optional dependency
- assert_equal(
- pkg_chk_sta(FAKE_NAME,
+ assert pkg_chk_sta(FAKE_NAME,
version='0.2',
optional='afeature',
- version_getter=bad_getter),
- {'extras_require': {'afeature': [FAKE_NAME + '>=0.2']}})
+ version_getter=bad_getter) == {'extras_require': {'afeature': [FAKE_NAME + '>=0.2']}}
finally:
del sys.modules[FAKE_NAME]
Index: nibabel-3.1.1/nisext/tests/test_testers.py
===================================================================
--- nibabel-3.1.1.orig/nisext/tests/test_testers.py
+++ nibabel-3.1.1/nisext/tests/test_testers.py
@@ -6,38 +6,37 @@ from os.path import dirname, pathsep
from ..testers import back_tick, run_mod_cmd, PYTHON
-from nose.tools import assert_true, assert_equal, assert_raises
-
+import pytest
def test_back_tick():
cmd = '{0} -c "print(\'Hello\')"'.format(PYTHON)
- assert_equal(back_tick(cmd), "Hello")
- assert_equal(back_tick(cmd, ret_err=True), ("Hello", ""))
- assert_equal(back_tick(cmd, True, False), (b"Hello", b""))
+ assert back_tick(cmd) == "Hello"
+ assert back_tick(cmd, ret_err=True) == ("Hello", "")
+ assert back_tick(cmd, True, False) == (b"Hello", b"")
cmd = '{0} -c "raise ValueError()"'.format(PYTHON)
- assert_raises(RuntimeError, back_tick, cmd)
+ with pytest.raises(RuntimeError):
+ back_tick(cmd)
def test_run_mod_cmd():
mod = 'os'
mod_dir = dirname(os.__file__)
- assert_equal(run_mod_cmd(mod, mod_dir, "print('Hello')", None, False),
- ("Hello", ""))
+ assert run_mod_cmd(mod, mod_dir, "print('Hello')", None, False) == ("Hello", "")
sout, serr = run_mod_cmd(mod, mod_dir, "print('Hello again')")
- assert_equal(serr, '')
+ assert serr == ''
mod_file, out_str = [s.strip() for s in sout.split('\n')]
- assert_true(mod_file.startswith(mod_dir))
- assert_equal(out_str, 'Hello again')
+ assert mod_file.startswith(mod_dir)
+ assert out_str == 'Hello again'
sout, serr = run_mod_cmd(mod,
mod_dir,
"print(os.environ['PATH'])",
None,
False)
- assert_equal(serr, '')
+ assert serr == ''
sout2, serr = run_mod_cmd(mod,
mod_dir,
"print(os.environ['PATH'])",
'pth2',
False)
- assert_equal(serr, '')
- assert_equal(sout2, '"pth2"' + pathsep + sout)
+ assert serr == ''
+ assert sout2 == '"pth2"' + pathsep + sout