Wait, what? So on windows would you say this is the test procedure:
Create ex47/tests/__init__.py file.
Create ex47/ex47/__init__.py file.
Create ex47/tests/simple_test.py and have it import ex47.game.
nosetests runs nothing.
Delete ex47/tests/__init__.py file.
nosetests runs simple_test.py.
If that’s true I have questions:
Why are all your paths in this “ex47/”? Are you inside that directory or above it?
Is there a way you can craft up two directories with just this as a demo? One nosetests fails and one that it runs in? If you can then I’d love to get it to figure out what’s going on.
My environment is Windows 10 64bit, Python 3.8.1, nosetests version 1.3.7, PowerShell version 5.1.18362.752.
I’m always running nosetests from the root of the project directory as shown below.
This is my initial result after completing exercises 46 & 47 with problem file shown: C:\USERS\HAWK_FW\PYTHON\PROJECTS\EX47 │ setup.py │ ├───bin ├───docs ├───ex47 │ │ game.py │ │ __init__.py │ │ │ └───__pycache__ ├───tests | │ ex47_tests.py | │ __init__.py <-------Problem File | │ | └───__pycache__
I had the same problem described by the OP. Resolved by moving the NAME_tests.py out of the tests directory into the skeleton directory. Will switch to pytest.
I also have this problem with nosetests running 0 tests.
I have removed the init.py file from ./skeleton/tests, and this returns an error BUT it runs 1 test. When I create the init.py file in ./skeleton/tests, ‘nosetests’ runs 0 tests.
Has a solution to this problem been found?
I have checked that the venv directory contains the script nosetests (it does). I have checked that .venvs/lpthw/Lib/site-packages/nose/tools contains scripts to import. I have tried running nosetests from all levels of the directory with no luck. I have carefully repeated the entire exercise multiple times.
Edit: I tried moving NAME_tests.py to the parent directory, ./skeleton/, and this successfully runs 1 test, BUT only when I run nosetests from ./skeleton. It does not run a test when I run it from ./skeleton/tests. This makes sense, but I am not sure why it would not run when NAME_tests.py when it was in ./skeleton/tests.
Thanks to @florian issue was resolved (by switching to pytest, lol). Not sure, at least now, how to properly read its output though.
Mr. @zedshaw since tool described in your book is obsolete now, maybe it will be helpful to create and pin a post about Pytest and basics of it’s usage? Like you pinned a forum rules.
Sort of “appendix” to ex.46.
I would if I had time but I’ve honestly been moving on Python entirely because of these very problems. If I ever finish my other work I’ll consider a rewrite of Python.