Unittest失败,出现ModuleNotFoundError,但鼻子测试成功

时间:2019-02-20 10:30:56

标签: python python-unittest nose

运行一组单元测试,由于缺少scipy模块,导致出现错误。通过nosetests运行相同命令,我失败。这怎么可能? nosetests搜索范围更广还是跳过测试?

使用python -m unittest discover

(py37a) gholl@oflws222:~/checkouts/pyorbital/pyorbital/tests> python -m unittest discover
E..EE..
======================================================================
ERROR: test_aiaa (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_aiaa
Traceback (most recent call last):
  File "/media/nas/x21324/miniconda3/envs/py37a/lib/python3.7/unittest/loader.py", line 434, in _find_test_path
    module = self._get_module_from_name(name)
  File "/media/nas/x21324/miniconda3/envs/py37a/lib/python3.7/unittest/loader.py", line 375, in _get_module_from_name
    __import__(name)
  File "/home/gholl/checkouts/pyorbital/pyorbital/tests/test_aiaa.py", line 36, in <module>
    from pyorbital.orbital import _SGDP4, Orbital, OrbitElements
  File "/media/nas/x21324/miniconda3/envs/py37a/lib/python3.7/site-packages/pyorbital/orbital.py", line 31, in <module>
    from scipy import optimize
ModuleNotFoundError: No module named 'scipy'

使用nosetests

(py37a) gholl@oflws222:~/checkouts/pyorbital/pyorbital/tests> nosetests
......................
----------------------------------------------------------------------
Ran 22 tests in 0.106s

OK

nosetests应该像python -m unittest discover那样失败时如何成功?

0 个答案:

没有答案