Exercise 46 Learn Python The Hard Way

Hello everyone, I am Python newbie and came from non CS degree but I am trying to understand the programming stuff from LPTHW.
I am using python 3.9 by the way
I would appreciate if anyone here could please explain it to me regarding exercise 46

I have installed the package mentioned in the book such as pip, distribute, nose, and virualenv (and several additional packages that my friend downloaded for me):

Next, I have made the directory bin, docs, NAME, tests, and the setup.py module inside the skeleton directory:
ex46

I have also made the setup.py inside skeleton directory and the Name_tests.py inside tests directory exactly the same like what had been written in the book:
ex462
ex461

I try to run the nosetests in Windows Power Shell in skeleton directory but gave me result Ran 0 tests (the book telling me to get Ran 1 on this command):
ex463

Then I tried to bring out the ‘Name_tests.py’ from tests directory to skeleton directory:
ex464

Then I run nosetests again with the Name_tests.py located inside skeleton directory and gave Ran 1 tests:
ex465

Can someone please explain to me what’s going on here? Why it gave me Ran 0 in the first trial, and gave me Ran 1 in the second trial. What is the difference between 0 and 1 result? What is actually the nosetests function here?

Thankyou very much for the explanation

The result is just the number of test functions that were found and executed.

You’ll find a lot of posts here about nose. In short: Don’t use it, it’s old, awkward, no longer actively maintained. Use pytest instead.

Owh i see, thanks @florian…test function here means any function with “tests” in it?, such as def tests_basic(): ?

And also I am curious about this if you don’t mind explaining about it:

PS C:\Users\asus\projects\skeleton> nosetests
‘Ran 0 tests’ when i clicked nosetests when module Name_tests.py located inside tests folder

PS C:\Users\asus\projects\skeleton> nosetests
‘Ran 1 tests’ when i clicked nosetests when module Name_tests.py located inside skeleton folder

Yes.

No I have no idea why nose behaves the way it does…

1 Like