Without environment variables, we know, the call is: python -m unittest tests.unit_test_1
But I need to pass environment variables as I need some values would be inserted in to the database whose creds are with me. I do not want to write it in a config/.py file, only pass them as environment variables. So if I pass the environment variables as:
python -m unittest tests.unit_test_1 $username $password
EDIT:
unit_test_1.py is somewhat as follows:
import unittest
from sys import argv
from os import environ
class database_helper_tests(unittest.TestCase):
def fetch(this):
x = connet_to_database(environ["username"], environ["password"])
data = x.fetch_from_database(this)
expected_output = ...
self.assertEqual(expected_output, data)
if __name__ == "__main__":
os["username"] = argv[1]
os["password"] = argv[2]
unittest.main()
The first test passes. And Then error I get is:
ModuleNotFoundError: No module named 'username"
ModuleNotFoundError: No module named 'password"
And finally I see this (although I am running just one test):
Ran 3 tests in 1.48s
What should I do so that I run only the test that is required?
Thank you in advance.
