django - 让 Pytest 在 Django cookiecutter/Python 3.x 项目中运行

标签 django node-modules cookiecutter-django

我正在构建一个新的 cookiecutter-django项目。这是 local setup instructions我已经关注了。

当我运行“pytest”时,我在尝试收集时遇到以下错误 7 次:

  • 收集 node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py 时出错
  • 收集 node_modules/node-gyp/gyp/pylib/gyp/common_test.py 时出错
  • 收集 node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py 时出错
  • 收集 node_modules/node-gyp/gyp/pylib/gyp/input_test.py 时出错
  • 收集 node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py 时出错
  • 收集 node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py 时出错
  • 收集 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
    

有什么想法吗?谢谢-

最佳答案

pytest 正在尝试加载您的 node_modules 目录。 node-gypdoes not support Python 3所以你得到了错误。你可以改变你的 test discovery排除 node_modules

与 mailhog 的第二个问题看起来无关。您可以尝试将 grunt 命令从 ./mailhog 更改为 /path/to/project/mailhog。我对grunt不熟悉所以不知道有没有更好的方案改路径。

关于django - 让 Pytest 在 Django cookiecutter/Python 3.x 项目中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47458933/

相关文章:

python - Django 如何安装 fork 应用程序

node.js - 在 Node V14 中从 std/esm 迁移到 esm 支持——找不到命名导入——与 std/esm 一起工作正常

python - 新鲜的 cookiecutter django 项目在 environ.py 中显示 "Invalid syntax"

django - Postgres : Password authentication failed for user "user". 角色 "user"不存在

python - 如何在 Django 的项目文件夹中创建数据库?

django - 使多个分组缓存键失效

javascript - 请求模块中的 dns 缓存 - node.js

visual-studio - 从 Visual Studio 2017 部署 Angular 2 应用程序

django - 无法从Django Docker实例内部访问项目绝对URL

Android-Django 图片上传