在测试期间manage.py刷新不起作用

时间:2019-03-21 10:25:09

标签: python django virtualenv pipenv

我正在使用有关如何使用Django Rest - React and it has some testing in it too的教程。当我测试它时,错误如下:

CypressError: cy.exec('npm run dev') timed out after waiting 60000ms

由于此错误发生在“之前”钩子期间,因此我们跳过了当前套件中的其余测试:“ Django REST framework / Rea ...”

下面是package.json的一部分,

{
  "name": "django-drf-react-quickstart",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "flush": "pipenv run python ./project/manage.py flush --no-input",
    "e2e": "cypress open --project ./project/frontend/",
    "dev": "webpack --mode development ./project/frontend/src/index.js --output ./project/frontend/static/frontend/main.js",
    "build": "webpack --mode production ./project/frontend/src/index.js --output ./project/frontend/static/frontend/main.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

我认为问题出在同花顺。我使用virtualenv,并且尝试了许多组合,例如:

  1. 运行python ./project/manage.py flush --no-input

  2. virtualenv运行python ./project/manage.py flush --no-input

  3. python ./project/manage.py冲洗-无输入

我什至尝试安装pipenv,但没有用。请帮助我。

1 个答案:

答案 0 :(得分:0)

我在本教程中遇到了类似的问题,对我帮助最大的是先安装pipenv,然后显式说明它和python的路径:

"flush": "./project_virtenv/bin/pipenv run ./project_virtenv/bin/python ./project/manage.py flush --no-input",