Getting Pytest to run in a Django cookiecutter / P

2019-07-30 17:02发布

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条回答
叛逆
2楼-- · 2019-07-30 17:51

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.

查看更多
登录 后发表回答