Tests not working in Travis CI

I am trying to deploy Travis CI in my Django/ Vue project. I added this .travis.yml file to my root folder:

language: python
python:
  - '3.7.3'
sudo: required
before_install:
  - chmod +x ./pizza/manage.py
before_script:
  - pip install -r requirements.txt
env: DJANGO_SETTINGS_MODULE="pizzago.settings"
services:
  - postgresql
script:
  - ./pizza/manage.py test --keepdb

But as I run the build I get this output:

   pip install -r requirements.txt
   ./pizza/manage.py test --keepdb
   System check identified no issues (0 silenced).
   Ran 0 tests in 0.000s
   OK
   The command "./pizza/manage.py test --keepdb" exited with 0.
   Done. Your build exited with 0.

Running my tests locally with 'python3 manage.py test --keepdb' works perfectly. My manage.py is not in my root folder. Looks like my tests are not found.

Hey @SolarUltima,

Your manage.py is not in your root directory but rather it’s /pizza/ directory. Travis should run the script inside this directory.

Change your .travis.yml to read this way (can lint this to make sure this works):

language: python
python:
  - '3.7.3'
sudo: required
before_install:
  - chmod +x ./pizza/manage.py
before_script:
  - pip install -r requirements.txt
  - cd ./pizza/
env: DJANGO_SETTINGS_MODULE="pizzago.settings"
services:
  - postgresql
script:
  - python manage.py test --keepdb

This will solve your issue hopefully, if it doesn’t please post back.

1 Like

hey @Montana those settings appear to work on the yaml file, on the test django app

-SU
Norway

Hey @SolarUltima,

No problem. I’ll link you to a gist, for a further example. Glad I could help.

Imprint