Reputation: 865
I have created a sample project [Django/Python] in a private repo on GitHub. Recently, I have a added a sample .travis.yml file to it in order to get CI rolling. Now issue is my tests [I am using Pytest suite] pass when I run the command pytest
on my local machine. But I am unable to get my test suite running on Travis
because of the above mentioned error. Any help in this regard will be appreciated.
Here's my sample .travis.yml
file.
language: python
sudo: false
python:
- '3.6.4'
services:
- mysql
addons:
apt:
sources:
- mysql-5.7-trusty
packages:
- mysql-server
cache:
directories:
- $HOME/.cache/pip
before_install:
- sudo mysql -e "use mysql; update user set password=PASSWORD('123123') where User='root';FLUSH PRIVILEGES;"
- sudo service mysql restart
before_cache:
- rm -f $HOME/.cache/pip/log/debug.log
install:
- pip install -r requirements/development.txt
before_script:
- sudo mysql -e 'CREATE DATABASE my_database;'
script:
- flake8
- pytest --cov -v --tb=native
notifications:
email:
on_success: change # [always|never|change]
on_failure: always # [always|never|change]
Just to add one more piece of info. My DB settings are as follows :
settings.py
.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'my_database',
'USER': 'root',
'PASSWORD': '123123',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '3306',
}
}
Upvotes: 0
Views: 860
Reputation: 1270
In your .travis.yml
use this to change the password:
before_install:
- sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('123123') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
- sudo mysql_upgrade -u root -p123123
- sudo service mysql restart
Or it's always best to use root
or travis
as username and leave the password blank.
Upvotes: 0