我为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结束 空的测试套件。
答案 0 :(得分:1)
如上所述here&#34;默认测试运行器&#34;必须在文件&gt;中设置为Nosetests设置&gt;工具&gt; Python集成工具对话框。但是,如果您已经尝试使用非Nosetests运行器运行(例如 Unittests似乎是默认值),那么您必须先删除现有配置。为此,请转到“运行”&gt;编辑配置,您将在&#34; Python测试&#34;它说&#34;在test_your_filename中进行单元测试。&#34;点击它,然后点击红色&#39; - &#39;要删除的框架顶部的按钮。