Closed mairsbw closed 8 years ago
Is your code open source? If so, where is it? If not, can you provide a minimal example that I could reproduce locally?
It's not open source. Let me whip up an example today so you can reproduce.
It doesn't get much more minimal than this.
Reproduce by running in the base folder the commands:
$ python -m green test # This will work!
$ python -m green test.test_mytest # This will fail!
$ python -m green test/test_mytest.py # This will also fail!
Oh, silly me. I should have caught that from your initial description. You're just missing an __init__.py
in your test folder. See the readme section here for a discussion on that very thing.
Yeah, I was wondering if it was a misconfiguration on my part. Thanks for your help.
Although now I have the problem where the name has changed for my test modules, so they can't find a relative path where some test files are kept (like os.path.join(__name__, 'images')
). Looks like instead of being named test_camera
my test_camera.py
script receives a name of test.test_camera
. So this is wrong for the path. I could hardcode these, but I liked using the name variable so it was the same between all of my test files. Any suggestions here?
I'm afraid if you want to use green to run specific tests, the specific test modules need to be in a package. When modules are in a package, their name is going to reflect that.
In your particular example, you could adjust for it pretty simply:
os.path.join(__name__.split('.')[-1], 'images')
Got it, that makes sense. Thanks.
I have a project with a
test
folder containing various test files that look liketest_XXX.py
. From the root directory of this project, running the entiretest
folder works fine:But if I try to just specify a subfile using the . pathing syntax:
And if I try to work around this by running the file directly:
So I'm uncertain what the right solution here is. Note that I'm not in a library (there's no init.py folder in the root directory that I'm running these scripts from), so I don't know if I have things set up incorrectly or if this is a failing on
green
's part.