问题
I am building a new cookiecutter-django project. Here are the local setup instructions which I've followed.
When I run "pytest" I get the following error 7 times when it tries to collect:
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/common_test.py
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/input_test.py
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py
- ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py
ERROR collecting node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py
../../Envs/kishikoi/lib/python3.6/site-packages/_pytest/python.py:395: in _importtestmodule mod = self.fspath.pyimport(ensuresyspath=importmode) ../../Envs/kishikoi/lib/python3.6/site-packages/py/_path/local.py:662: in pyimport __import__(modname) E File "/Users/emilepetrone/Sites/kishikoi/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 37 E print '%s:%s:%d:%s %s' % (mode.upper(), os.path.basename(ctx[0]), E ^ E SyntaxError: invalid syntax
Any ideas? Thank you-
回答1:
pytest is trying to load your node_modules directory. The node-gyp
package does not support Python 3 so you get the error. You could change your test discovery to exclude node_modules
.
The second issue with mailhog looks unrelated. You could try changing the grunt command from ./mailhog
to /path/to/project/mailhog
. I'm unfamiliar with grunt so I don't know if there's a better solution to change the path.
来源:https://stackoverflow.com/questions/47458933/getting-pytest-to-run-in-a-django-cookiecutter-python-3-x-project