Running Nosetest on Ex47?


#21

I understand now. The program did run, it just had nothing to display as no functions were called. This is why there were no error messages. I tried to include print statements, but those did not print anything, which I assume is because I did not call the function.

I thought ex47_tests.py would run as I did not understand that “testing” the code meant using nosetests, instead of running the program using a python command. This is why the nil result confused me.

I am assuming that nosetests catches failures that would not show up when running modules(?) using the python command on its own.


#22

Yep, bingo! Now you get it. Basically, the code is just fine. You just have to use nosetests to run the test code. You should also take a look at pytest:

https://docs.pytest.org/en/latest/

It is a little easier to use and is actually maintained.


#23

Hi Zed,
While on ex47, I ran into a problem with nosetests. Nosetests ran 3 tests on my ex47 and returned 3 fails all indicating the same TypeError: object() takes no parameters. The first error message is as follows:

self.test(*self.arg)

File “/Users/mchen/projects/ex47/ex47_tests.py”, line 8, in test_room
“”" This room has gold in it you can grab. There’s a door to the north.""")
TypeError: object() takes no parameters

Could you shed some light on where the problems are? Thanks.


#24

I found out it is my own error to blame. The error message is caused by my mis-spelling of init in class Room and has nothing to do with nosetests. My bad.


#25

Then I guess the test worked!