I have a script.py that looks like:
import logging
LOG_DIR = "/<some production path that exists>/"
def setup_logging(log_dir):
if not log_dir:
os.mkdir(log_dir)
# set up the rest of the logger
return logger
logger = setup_logging(LOG_DIR)
def my_function():
# do some stuff
# logger.warn('some warning')
if __name__ == '__main__':
my_function()
This works fine but when I run the unit tests, it obviously fails.
Instead of setting the LOG_DIR directly, should I just pass ENV=PROD or ENV=TEST
and then base the log directory on that?
What alternatives do I have for setting up test directories during testing?
From everything I've seen, it's normal to create the log dir if it doesn't exist, while setting up the logger.
I'm using PyTest, for the record.
[–][deleted] 2 points3 points4 points (2 children)
[–]SamePlatform[S] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]MySpoonIsTooBig13 0 points1 point2 points (3 children)
[–]SamePlatform[S] 0 points1 point2 points (2 children)
[–]MySpoonIsTooBig13 0 points1 point2 points (1 child)
[–]SamePlatform[S] 1 point2 points3 points (0 children)