I've tried to google this but nothing helpful is coming up.
Basically I have an src folder, and within it are two modules - app.py and app_test.py. In app, there are about 17 functions, and I've written a test for one of them in app_test. A very simple one that checks whether a filepath is being created properly.
But when I click on "Run Tests", what happens? My whole app.py code runs. I tried with UnitTests instead and get an error that a relative path doesn't exist...which is not referenced anywhere in app_test or the simple test that exists in there on its own. The same thing happens if I run pytest src/app_test.py from the command line.
I'm assuming I've set something up wrong but can't work out what!
hoefling solved it in the comments! probably super obvious to most but in case anybody else is struggling -
Probably because you have code in app.py on script level that runs on import and should be put under if name == "main":
Why would pytest be running full code rather than tests when I click "Run Tests"?