[PYTHON] I want to separate the processing between test time and production environment

I really wanted to separate the processing at the time of testing. Let's judge from the file name of the runtime argument using sys.argv.

import sys

if 'test_loader.py' in sys.argv:
    db = load_database('test')
else:
    db = load_database('production')

runtime

python test_loader.py

But if you need to call test_loader from another script, this is not the way to go. ..

test_loader.py:

import os
if not os.getenv('DB'):
    os.environ['DB'] = 'test'

Recommended Posts

I want to separate the processing between test time and production environment
I want to record the execution time and keep a log.
Python: I want to measure the processing time of a function neatly
I want to make a music player and file music at the same time
I want to move selenium for the time being [for mac]
I tried to illustrate the time and time in C language
I tried to display the time and today's weather w
I want to know the features of Python and pip
I tried to enumerate the differences between java and python
I want to map the EDINET code and securities number
I want to create a Dockerfile for the time being.
I want to absorb the difference between the for statement on the Python + numpy matrix and the Julia for statement
I want to use the Ubuntu desktop environment on Android for the time being (Termux version)
I want to use Ubuntu's desktop environment on Android for the time being (UserLAnd version)
LINEbot development, I want to check the operation in the local environment
I want to connect remotely to another computer, and the nautilus command
For the time being, I want to convert files with ffmpeg !!
I want to pass the G test in one month Day 1
I tried to create serverless batch processing for the first time with DynamoDB and Step Functions
I want to pin Spyder to the taskbar
I want to output to the console coolly
I want to handle the rhyme part1
I want to handle the rhyme part3
I want to build a Python environment
I want to display the progress bar
I want to handle the rhyme part2
I want to handle the rhyme part5
I want to handle the rhyme part4
I want to analyze the emotions of people who want to meet and tremble
I want to use Ubuntu's desktop environment on Android for the time being (Termux version-Japanese input in desktop environment)
I want to visualize where and how many people are in the factory
I want to do Dunnett's test in Python
I want to use Python in the environment of pyenv + pipenv on Windows 10
I want to handle the rhyme part7 (BOW)
I don't want to take a coding test
I want to manage systemd by time zone! !!
I want to store the result of% time, %% time, etc. in an object (variable)
I want to use mkl with numpy and scipy under pyenv + poetry environment
I want to get the file name, line number, and function name in Python 3.4
I tried to pass the G test and E qualification by training from 50
I want to customize the appearance of zabbix
I want to use the activation function Mish
I want to display the progress in Python!
[Writing] I want to display the variables used in the program on the server side in real time on the browser and update them.
I want to replace the variables in the python template file and mass-produce it in another file.
I want to create a lunch database [EP1] Django study for the first time
I want to create a lunch database [EP1-4] Django study for the first time
I just wanted to extract the data of the desired date and time with Django
[Memorandum] ① Get and save tweets ~ I want to identify the news tweets that are spread ~
How to test the current time with Go (I made a very thin library)
I tried to compare the processing speed with dplyr of R and pandas of Python
I want to be notified of the connection environment when the Raspberry Pi connects to the network
I want to see the file name from DataLoader
100 image processing knocks !! (021-030) I want to take a break ...
I want to grep the execution result of strace
I want to scroll the Django shift table, but ...
I want to handle optimization with python and cplex
[Python] Measures and displays the time required for processing
I want to write in Python! (2) Let's write a test
I want to inherit to the back with python dataclass
I want to fully understand the basics of Bokeh