[kwlug-disc] Python tests in a subfolder

Paul Nijjar paul_nijjar at yahoo.ca
Mon Apr 17 17:09:10 EDT 2017


I have the following directory structure: 

project_folder:
- my_script.py
- config.py
- tests/
  + test_script.py

my_script.py is a simple script with a few helper functions. It is not
meant to be a module. 

I am trying to set up pytest so that it will be able to see and run
the helper functions in my_script.py . But I do not understand what
structure I need. There is the following question: 

http://stackoverflow.com/questions/26804421

but that makes it seem as if I have to turn my_script.py into a
module. Running that setuptools command near the bottom of the answer
creates a gross my_package.egg-info folder in the root folder of my
project. 

Clearly I am not understanding something simple, but I have not been
understanding this simple thing for over two days. Is it feasible for
me to structure my code and tests in this way? What import do I have
to do in test_script.py to make it find my_script.py? Or am I stuck
making this a module? Then I read other answers that says calling a
script inside a module is an antipattern, and then I get even more
frustrated.

I am using python 3.4 in a virtualenv. 

I know this is a simple beginner question, but it is making me so
frustrated. I could really use some beginner help here. 


-- 
http://pnijjar.freeshell.org




More information about the kwlug-disc mailing list