Hey,
I keep running into this error for when it hits “run tests” in my build.
I’ve tried multiple variations of the django example, still to no avail.
Here is what my config.yml looks like
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8.0
environment:
DJANGO_SECRET_KEY: "LOLLLLLLL"
# PIPENV_VENV_IN_PROJECT: true
# DATABASE_URL: mysql://root@localhost/circle_test?sslmode=disable
- image: circleci/mysql:8.0.4
environment:
MYSQL_ROOT_PASSWORD: rootpw
MYSQL_DATABASE: test_db
MYSQL_USER: user
MYSQL_PASSWORD: passw0rd
steps:
- checkout
- run: sudo chown -R circleci:circleci /usr/local/bin
- run: sudo chown -R circleci:circleci /usr/local/lib/python3.8/site-packages
- restore_cache:
key: deps10-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
- run:
command: |
sudo pip install pipenv
pipenv install
- save_cache:
key: deps10-{{ .Branch }}-{{ checksum "Pipfile.lock" }}
paths:
- '.venv'
- '/usr/local/bin'
- '/usr/local/lib/python3.8/site-packages'
- run:
command: |
pipenv run python manage.py test
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: tr1
other variations of this are
version: 2
jobs:
build:
docker:
- image: circleci/python:3.8.0
environment:
DJANGO_SECRET_KEY: "LOLLLLLLL"
TEST_DATABASE_PREFIX: "fuck"
steps:
- checkout
- restore_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
- run:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
- save_cache:
key: deps1-{{ .Branch }}-{{ checksum "requirements.txt" }}
paths:
- "venv"
- run:
name: Running tests
command: |
. venv/bin/activate
python3 manage.py test
- store_artifacts:
path: test-reports/
destination: python_app
and the config from this issue Django Postgres test_database already exists
regardless, my error persists and my traceback is this
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/commands/test.py", line 23, in run_from_argv
super().run_from_argv(argv)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/core/management/commands/test.py", line 53, in handle
failures = test_runner.run_tests(test_labels)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/test/runner.py", line 629, in run_tests
old_config = self.setup_databases(aliases=databases)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/test/runner.py", line 554, in setup_databases
self.parallel, **kwargs
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/test/utils.py", line 157, in setup_databases
test_databases, mirrored_aliases = get_unique_databases_and_mirrors(aliases)
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/test/utils.py", line 258, in get_unique_databases_and_mirrors
default_sig = connections[DEFAULT_DB_ALIAS].creation.test_db_signature()
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/db/backends/base/creation.py", line 295, in test_db_signature
self._get_test_db_name(),
File "/home/circleci/project/venv/lib/python3.6/site-packages/django/db/backends/base/creation.py", line 153, in _get_test_db_name
return TEST_DATABASE_PREFIX + self.connection.settings_dict['NAME']
TypeError: must be str, not NoneType
Not sure what I’m missing, any insight, constructive criticism, help, would be greatly appreciated!
So after digging around some more, it seems like my connection.settings_dict
keys are all None when i run my build, is there a way to set these? below is what appears when i print connection.settings_dict
would love to be able to know if there’s an env i’m missing or what not
{
'ENGINE': 'django.db.backends.mysql',
'NAME': None,
'USER': None,
'PASSWORD': None,
'HOST': None,
'PORT': None,
'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'OPTIONS': {},
'TIME_ZONE': None,
'TEST': {
'CHARSET': None,
'COLLATION': None,
'NAME': None,
'MIRROR': None
}
}