当我保存文件时,我试图让测试持续运行。
我试着用爱管闲事。
我可以运行我的测试python test_1.py
$ python test_1.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
但是nose2给出了
$ nose2
----------------------------------------------------------------------
Ran 0 tests in 0.000s
OK
E
======================================================================
ERROR: test_1 (nose2.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: test_1
Traceback (most recent call last):
File "/home/durrantm/.local/lib/python3.7/site-packages/nose2/plugins/loader/discovery.py", line 201, in _find_tests_in_file
module = util.module_from_name(module_name)
File "/home/durrantm/.local/lib/python3.7/site-packages/nose2/util.py", line 77, in module_from_name
__import__(name)
File "/home/durrantm/Dropbox/90_2019/work/code/pair_and_mob/python/for_nose_2/test_1.py", line 10, in <module>
unittest.main()
File "/usr/lib/python3.7/unittest/main.py", line 101, in __init__
self.runTests()
File "/usr/lib/python3.7/unittest/main.py", line 273, in runTests
sys.exit(not self.result.wasSuccessful())
SystemExit: False
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
$ cat test_1.py
import unittest
from mycode import *
class MyFirstTests(unittest.TestCase):
def test_hello(self):
self.assertEqual(hello_world(), 'hello world')
def test_goodbye(self):
self.assertEqual(goodbye_world(), 'goodbye world')
unittest.main()
$ cat mycode.py
def hello_world():
return 'hello world'
def goodbye_world():
return 'goodbye world'