It was just three weeks, I started learning python and speeding up so fast to pick many things. Honestly I jumped into the ocean without knowing swimming.
Unfortunately, I got stuck at one point for many hours and could not find the issue after referring many answers in stackoverflow.
Let me explain,
I have the following project folder structure along with python files,
|-transform
|---mask
|-----config/
application_config.json
|-----logs
|-----mask/
mask.py
constants.py
maskconfigparser.py
|-----tests/
test_string_parser.py
test_string_parser.py
should call mask.py
in the mask
folder so that it executes by reading configuration in the config
folder.
Here is the code in test_string_parser.py
import unittest
from pathlib import Path
import importlib.util
import sys
sys.path.insert(1, '/transform/mask/')
class TestStringMasking(unittest.TestCase):
def test_string_masking(self):
spec = importlib.util.spec_from_file_location(
"mask",
"/transform/mask/mask/mask.py")
mask_module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mask_module)
if __name__ == '__main__':
unittest.main()
I call the tests from linux script file run_tests.sh
as shown below.
export PYTHONPATH="${PYTHONPATH}:/transform/mask/mask/"
python -m unittest discover -v
when I run the sh script, the mask.py was never executed and I could not find what was the issue while there is no error.
Please help and advice.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…