python - 使用 Pycharm 运行 Nosetests 并获得 "Empty test suite"

标签 python python-2.7 automated-tests pycharm nosetests

我为 Python 代码编写了测试套件。我没有设法配置 Pycharm 来识别这个测试套件。使用 Nose-test 运行它时,我在 Pycharm 控制台收到以下消息:

Empty test suite

完整日志如下:

Testing started at 2:12 PM ...

nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.plugins.manager: DEBUG: Configuring plugins
nose.plugins.manager: DEBUG: Plugins enabled: [<nose_utils.TeamcityPlugin run=0     errors=0 failures=0>, <nose_unittest.plugin.UnitTestPlugin object at 0x1a4fcd0>, <nose.plugins.logcapture.LogCapture object at 0x1a57c90>, <nose.plugins.deprecated.Deprecated object at 0x1a5ab90>, <nose.plugins.skip.Skip object at 0x1c07a10>, <nose.plugins.xunit.Xunit object at 0x1c07b10>]
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.plugins.manager: DEBUG: Configuring plugins
nose.plugins.manager: DEBUG: Plugins enabled: [<nose_unittest.plugin.UnitTestPlugin object at 0x1a4fcd0>, <nose.plugins.xunit.Xunit object at 0x1c07b10>, <nose_utils.TeamcityPlugin run=0 errors=0 failures=0>, <nose.plugins.deprecated.Deprecated object at 0x1a5ab90>, <nose.plugins.skip.Skip object at 0x1c07a10>, <nose.plugins.logcapture.LogCapture object at 0x1a57c90>]
nose.core: DEBUG: configured Config(addPaths=True, args=(), configSection='nosetests', debug=None, debugLog=None, env={}, exclude=None, firstPackageWins=False, getTestCaseNamesCompat=False, ignoreFiles=[<_sre.SRE_Pattern object at 0x1a483b0>, <_sre.SRE_Pattern object at 0x1a482b0>, <_sre.SRE_Pattern object at 0x1a40270>], ignoreFilesDefaultStrings=['^\\.', '^_', '^setup\\.py$'], include=None, includeExe=False, logStream=<open file '<stderr>', mode 'w' at 0x7f9587bba1e0>, loggingConfig=None, options=<Values at 0x1c65560: {'xunit_file': 'nosetests.xml', 'enable_plugin_allmodules': None, 'multiprocess_restartworker': False, 'testconfigencoding': 'utf-8', 'loggingConfig': None, 'doctestExtension': None, 'doctest_tests': None, 'enable_plugin_unittest': None, 'testconfig': None, 'debugBoth': False, 'logcapture_clear': False, 'stopOnError': False, 'enable_plugin_id': None, 'testNames': None, 'doctestOptions': None, 'exclude': [], 'byteCompile': True, 'ignoreFiles': [], 'logcapture': True, 'addPaths': True, 'capture': False, 'logcapture_level': 'NOTSET', 'cover_xml': None, 'py3where': None, 'noSkip': False, 'enable_plugin_isolation': None, 'logcapture_filters': None, 'collect_only': None, 'failed': False, 'enable_plugin_TeamcityPlugin': None, 'eval_attr': None, 'version': False, 'overrides': [], 'include': [], 'enable_plugin_profile': None, 'debugErrors': False, 'files': None, 'cover_tests': None, 'multiprocess_timeout': 10, 'testMatch': '(?:^|[\\b_\\./-])[Tt]est', 'traverseNamespace': False, 'testconfigformat': 'ini', 'firstPackageWins': False, 'cover_html_dir': 'cover', 'cover_branches': None, 'enable_plugin_xunit': True, 'noDeprecated': False, 'cover_xml_file': 'coverage.xml', 'showPlugins': False, 'cover_erase': None, 'multiprocess_workers': 0, 'exact': False, 'testIdFile': '.noseids', 'enable_plugin_coverage': None, 'attr': None, 'profile_sort': 'cumulative', 'doctestFixtures': None, 'logcapture_datefmt': None, 'cover_packages': None, 'profile_restrict': None, 'enable_plugin_doctest': None, 'profile_stats_file': None, 'cover_inclusive': None, 'includeExe': False, 'logcapture_format': '%(name)s: %(levelname)s: %(message)s', 'debugFailures': False, 'detailedErrors': None, 'debugLog': None, 'doctest_result_var': None, 'cover_html': None, 'debug': None, 'cover_min_percentage': None, 'where': None, 'verbosity': 4}>, parser=<optparse.OptionParser instance at 0x1a497e8>, parserClass=<class optparse.OptionParser at 0x7f9586056808>, plugins=<nose.plugins.manager.DefaultPluginManager object at 0x1a47510>, py3where=(), runOnInit=True, srcDirs=('lib', 'src'), stopOnError=False, stream=<open file '<stderr>', mode 'w' at 0x7f9587bba1e0>, testMatch=<_sre.SRE_Pattern object at 0x19e8330>, testMatchPat='(?:^|[\\b_\\./-])[Tt]est', testNames=['/home/faina/seculert/seculert/trunk/pymodules/seculert/integration_tests/sense/testSenseE2E.py'], traverseNamespace=False, verbosity=4, where=(), worker=False, workingDir='/home/faina/seculert/seculert/trunk/pymodules/seculert/integration_tests/sense')
nose.importer: DEBUG: Add path /home/trunk/pymodules/integration_tests/x
nose.importer: DEBUG: Add path /home/trunk/pymodules/integration_tests
nose.importer: DEBUG: Add path /home/trunk/pymodules
nose.core: DEBUG: test loader is <nose.loader.TestLoader object at 0x1c07fd0>
nose.core: DEBUG: defaultTest .
nose.core: DEBUG: Test names are ['/home/trunk/pymodules/integration_tests/x/testx.py']
nose.core: DEBUG: createTests called with None
nose.loader: DEBUG: load from /home/trunk/pymodules/integration_tests/x/testx.py (None)
nose.selector: DEBUG: Test name /home/trunk/pymodules/integration_tests/x/testx.py resolved to file /home/trunk/pymodules/integration_tests/x/testx.py, module None, call None
nose.selector: DEBUG: Final resolution of test name /home/trunk/pymodules/integration_tests/sense/testSenseE2E.py: file /home/trunk/pymodules/integration_tests/x/testx.py module integration_tests.x.testx call None
nose.importer: DEBUG: Import integration_tests.x.testx from /home/trunk/pymodules
nose.importer: DEBUG: Add path /home/trunk/pymodules
nose.importer: DEBUG: find module part x (x) in ['/home/trunk/pymodules']
nose.importer: DEBUG: find module part integration_tests (integration_tests) in ['/home/trunk/pymodules']
nose.importer: DEBUG: find module part x (integration_tests.x) in ['/home/trunk/pymodules/integration_tests']
nose.importer: DEBUG: find module part testx (integration_tests.x.testx) in ['/home/trunk/pymodules/integration_tests/x']
nose.loader: DEBUG: Load from module <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>
nose.selector: DEBUG: Plugin setting selection of managers.bashManager.BashManager to False
nose.selector: DEBUG: wantClass managers.bashManager.BashManager? False
nose.suite: DEBUG: Create suite for <nose.suite.ContextList object at 0x2315790>
nose.suite: DEBUG: tests <nose.suite.ContextList object at 0x2315790> context <module 'integration_tests.sense.testSenseE2E' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>
nose.suite: DEBUG: Context suite for <nose.suite.ContextList object at 0x2315790> (<module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>) (36788176)
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.x.testx> has context integration_tests.x.testx
nose.suite: DEBUG: get ancestry <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>
nose.suite: DEBUG:  <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> ancestors ['integration_tests', 'x']
nose: DEBUG: __import__ integration_tests.x
nose: DEBUG: resolve: ['integration_tests', 'x'], integration_tests.x, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.x.testx> has ancestor integration_tests.sense
nose.suite: DEBUG:  <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> ancestors [ 'integration_tests']
nose: DEBUG: __import__ integration_tests
nose: DEBUG: resolve: ['integration_tests'], integration_tests, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.x.testx> has ancestor integration_tests
nose.suite: DEBUG:  <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> ancestors ['x']
nose: DEBUG: __import__ x
nose: DEBUG: resolve: [], x, <module 'x' from '/home/pymodules/__init__.pyc'>, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.sense.testx> has ancestor x
nose.suite: DEBUG: Create suite for [<nose.suite.ContextSuite context=integration_tests.x.testx>]
nose.suite: DEBUG: tests [<nose.suite.ContextSuite context=integration_tests.x.testx>] context None
nose.suite: DEBUG: wrap [<nose.suite.ContextSuite context=integration_tests.x.testx>]
nose.suite: DEBUG: wrapping <nose.suite.ContextSuite context=integration_tests.x.testx>
nose.suite: DEBUG: Context suite for [<nose.suite.ContextSuite context=integration_tests.x.testx>] (<module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>) (29782416)
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.x.testx> has context integration_tests.x.testx
nose.suite: DEBUG: get ancestry <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>
nose.suite: DEBUG:  <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> ancestors ['x', 'integration_tests']
nose: DEBUG: __import__ integration_tests
nose: DEBUG: resolve: ['integration_tests'], integration_tests, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>, <module 'x' from '/home/trunk/pymodules/__init__.pyc'>
nose.suite: DEBUG: suite <nose.suite.ContextSuite context=integration_tests.x.testx> has ancestor integration_tests
nose.suite: DEBUG:  <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> ancestors ['x']
nose.core: DEBUG: runTests called
nose.suite: DEBUG: suite 29782416 (<nose.suite.ContextSuite context=integration_tests.x.testx>) run called, tests: <generator object _get_wrapped_tests at 0x240f1e0>
nose.suite: DEBUG: suite 29782416 setUp called, tests: <generator object _get_wrapped_tests at 0x240f410>
nose.suite: DEBUG: tests in 29782416?
nose.suite: DEBUG: ancestor <module 'seculert' from '/home/trunk/pymodules/__init__.pyc'> may need setup
nose.suite: DEBUG: ancestor <module 'seculert' from '/home/trunk/pymodules/__init__.pyc'> does need setup
nose.suite: DEBUG: <nose.suite.ContextSuite context=integration_tests.x.testx> setup context <module 'x' from '/home/trunk/pymodules/__init__.pyc'>
nose.suite: DEBUG: ancestor <module 'integration_tests' from '/home/trunk/pymodules/integration_tests/__init__.pyc'> may need setup
nose.suite: DEBUG: ancestor <module 'integration_tests' from '/home/trunk/pymodules/integration_tests/__init__.pyc'> does need setup
nose.suite: DEBUG: <nose.suite.ContextSuite context=integration_tests.x.testx> setup context <module 'integration_tests' from '/home/trunk/pymodules/integration_tests/__init__.pyc'>
nose.suite: DEBUG: ancestor <module 'integration_tests.x' from '/home/trunk/pymodules/integration_tests/x/__init__.pyc'> may need setup
nose.suite: DEBUG: ancestor <module 'integration_tests.x' from '/home/trunk/pymodules/integration_tests/x/__init__.pyc'> does need setup
nose.suite: DEBUG: <nose.suite.ContextSuite context=integration_tests.x.testx> setup context <module 'integration_tests.x' from '/home/trunk/pymodules/integration_tests/x/__init__.pyc'>
nose.suite: DEBUG: ancestor <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> may need setup
nose.suite: DEBUG: ancestor <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> does need setup
nose.suite: DEBUG: <nose.suite.ContextSuite context=integration_tests.x.testx> setup context <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'>
nose.suite: DEBUG: completed suite setup
nose.suite: DEBUG: precache is [<nose.suite.ContextSuite context=integration_tests.x.testx>]
nose.suite: DEBUG: suite 36788176 (<nose.suite.ContextSuite context=integration_tests.x.testx>) run called, tests: <generator object _get_wrapped_tests at 0x240f550>
nose.suite: DEBUG: suite 36788176 setUp called, tests: <generator object _get_wrapped_tests at 0x240f550>
nose.suite: DEBUG: tests in 36788176?
nose.suite: DEBUG: suite 36788176 has no tests
nose.suite: DEBUG: precache is []
nose.suite: DEBUG: context teardown
nose.suite: DEBUG: No reason to teardown (was_setup? False was_torndown? False)
nose.suite: DEBUG: context teardown
nose.suite: DEBUG: ancestor <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> may need teardown
nose.suite: DEBUG: ancestor <module 'integration_tests.x.testx' from '/home/trunk/pymodules/integration_tests/x/testx.pyc'> already torn down

----------------------------------------------------------------------
XML: nosetests.xml
----------------------------------------------------------------------
Ran 0 tests in 0.002s

OK

进程结束,退出代码为 0 空测试套件。

最佳答案

如前所述here “默认测试运行器”必须在"file">“设置”>“工具”>“Python 集成工具”对话框中设置为 Nosetests。但是,如果您已经尝试使用非 Nosetests 运行器(例如 Unittests 似乎是默认设置)运行,那么您必须先删除现有配置。为此,请转到“运行”>“编辑配置”,您会在“Python 测试”下看到“Unittests in test_your_filename”。单击它,然后单击框架顶部的红色“-”按钮以删除。

关于python - 使用 Pycharm 运行 Nosetests 并获得 "Empty test suite",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23472452/

相关文章:

Python 记录重复的日志条目

python-2.7 - 滚动请求中的 "batch of results"大小是多少

unit-testing - Boost 测试与 Google 测试框架

java - 记录selenium中页面的加载(打开/关闭)和搜索时间

unit-testing - 如何比较两种环境之间的 Karate 测试结果?

python - 关闭文件后如何在内存中保留一个 h5py 组?

Python 与代码一起定义单元测试类

Python OpenCV 视频格式浏览器播放

Python 2.7 Anaconda Pandas 错误(Ubuntu 14.04)

python - 将 10 分钟和 30 分钟 NETCDF 时间序列转换为每小时 + 在 Python 中删除 NaN 的函数?