Greetings
i really need a help
i am setting up a project that project have .env where i have to put all
my database credentials and all settings that i may wish to customize i
followed up all the steps but at the end i am facing a challenge
when i run the tests
from dotenv import load_dotenv, find_dotenv #type: ignore
E ImportError: cannot import name 'load_dotenv' from 'dotenv'
(/home/rdm/OUt/venv/lib/python3.8/site-packages/dotenv.py)
exec(co, module.__dict__)
saskatoon/tests/conftest.py:6: in <module>
from dotenv import load_dotenv, find_dotenv #type: ignore
E ImportError: cannot import name 'load_dotenv' from 'dotenv'
(/home/rdm/OUTREACH/venv/lib/python3.8/site-packages/dotenv.py)
=========================== short test summary info
============================
ERROR - ImportError: cannot import name 'load_dotenv' from 'dotenv'
(/home/r...
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection
!!!!!!!!!!!!!!!!!!!!
=============================== 1 error in 3.00s
===============================
(venv) rdm@RDM:~/OUTREACH/saskatoon-ng$ saskatoon/tests/runtests.sh
Starting tests in a bit ...
i installed python-dotenv but still the same response i am getting
Thank you for the help
contests.py
import os
import pytest
import selenium.webdriver
from django.conf import settings
from dotenv import load_dotenv, find_dotenv #type: ignore
# Load the environment variables from .env file.
file = find_dotenv()
if file: load_dotenv(dotenv_path=file)
TESTDRIVER = os.getenv('SASKATOON_TEST_WEBDRIVER')
Settings .py
import os
from pathlib import Path
from dotenv import read_dotenv
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Load the environment variables from .env file.
dotenv = os.path.join(BASE_DIR, '.env')
if os.path.exists(dotenv):
read_dotenv(dotenv=dotenv)
else:
raise IOError('.env file not found!')
.env file
## Database (mysql) ##
SASKATOON_DB_ENGINE=django.db.backends.mysql
SASKATOON_DB_NAME=saskatoon_dev
SASKATOON_DB_USER=richard
SASKATOON_DB_PASSWORD=@richdush1
SASKATOON_DB_HOST=127.0.0.1
Best Regards
Dushime Mudahera Richard
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAJCm56J6vFzb%2ByWfmrkFd6pWo%3D79FBVWxCjGwUeKjjihiKZx-Q%40mail.gmail.com.