Python의 인터프리터가 PyCharm에서 nose 설정 파일의 설정을로드하지 않습니다. PyCharm에서 설정 파일을 사용하려면 어떻게해야합니까? 나는 또한 이유를 이해하고 싶습니다.Pycharm이 nosetests 설정 파일을 사용하지 않음
그것은 설정이 PARAMS PyCharm의 내 인스턴스뿐만 아니라 설정 파일 및 에서 를 제공하는 것이 매우 중요합니다. 필자가 제공 한 설정에는 3 개의 파일 만 있지만 테스트 설정을 공동으로 공유 할 수있는 대답을 사용하게됩니다. 여기
는 설정이다 :
~/PycharmProjects/Testing/test_suite.py
~/PycharmProjects/Testing/unnecessary_math.py
~/nose.cfg
는 "nose.cfg"설정이 인식 (PyCharm 외부) 인터프리터를 통해 실행 및 제공 달렸다 :
Marcs-MacBook-Pro:Testing marcs$ nosetests -s .
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
Doctest: unnecessary_math.divide ... ok
Doctest: unnecessary_math.multiply ... ok
Starting Test
['/Users/marcs/nose.cfg']
test_suite.test_numbers_0_4 ... ok
test_suite.test_num_4_4_4_4 ... ok
Ending Test
----------------------------------------------------------------------
XML: nosetests.xml
----------------------------------------------------------------------
Ran 4 tests in 0.008s
OK
Marcs-MacBook-Pro:Testing marcs$
하는 PyCharm에서 실행하는 경우 나는이 출력을 얻는다.
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Applications/PyCharm.app/helpers/pydev/pydevd.py --multiproc --client 127.0.0.1 --port 61446 --file /Applications/PyCharm.app/helpers/pycharm/noserunner.py /Users/marcs/PycharmProjects/Testing/ -s
Testing started at 5:36 AM ...
pydev debugger: process 10464 is connecting
Connected to pydev debugger (build 133.881)
Starting Test
['/Users/marcs/nose.cfg']
..
..
Ending Test
----------------------------------------------------------------------
Ran 2 tests in 0.023s
OK
Process finished with exit code 0
그래서 나는 그것을 볼 수있는 것으로 보인다. e PyCharm의 환경은 nose.cfg 파일을 인식하지만 어떤 이유로 그것을로드하지 않도록 선택합니다. 나는 이유를 모른다.
나는 아래의 파일의 소스 코드를 포함 시켰습니다:
from unnecessary_math import multiply
from nose.tools import assert_equals
import nose.config as config
def setup_module():
print "Starting Test"
print config.all_config_files()
def teardown_module():
print "Ending Test"
def test_numbers_0_4():
assert_equals(multiply(0,4), 0)
def test_num_4_4_4_4():
assert_equals(multiply(4,4,4,4), 256)
unnecessary_math.py
~/nose.cfg
[nosetests]
verbosity=3
with-doctest=1
with-xunit=1
test_suite.py을
def multiply(*args):
"""
This function multiplies any number of integers together
'Given a list of numbers it will give you their commutative product'
>>> multiply(4,4)
16
>>> multiply(4,4,4,4)
256
>>>
"""
product = 1
for arg in args:
product = product * arg
return product
def divide(a,b):
"""
This function divides a by b
'b divides a'
>>> divide(4,4)
1
>>> divide(8,2)
4
>>>
>>> divide(5,2)
2
>>>
"""
return a/b
이 문제를 다시 조사했습니다. 나는 여전히 대답이 없지만 동일한 파일 구조를 유지하고 같은 폴더 내에서 nosetest를 실행하는 동안 "__ init __.py"를 추가하면 똑같은 동작을 PyCharm 외부의 똑같은 코드 검사에서 복제 할 수있었습니다. . 폴더 외부에서 실행될 때는 정상적으로 작동하지만 폴더 내에서는 PyCharm처럼 작동합니다 (cfg 파일 무시). PyCharm에서 문제를 해결했는지 확인하려고 시도했지만 시도하지 않았습니다. – Marc