I get assertion error while testing a file for single linked list

in test_sllist.py of exercise 13 of lmpthw, running nosetests throws the assertion error as shown in the screenshot. the codes of script sllist.py is:

and that of script test_sllist.py is:

i don’t get why am i getting this assertion error.

Well, you can’t run tests before you’ve written your functions. They’re only placeholders now, nothing happens!

1 Like

oh that means, i need to write codes for those ten operations-
push
pop
shift
unshift
remove
first
last
count
get
and dump myself, right?

Hello @vijayaavaas

My suggestion is that you take the opportunity to do TDD (test driven development)
I havent started yet with LMPTHW, but this seems to be a perfect way to do the exercise and try TDD.

I hope this is a useful advice.

1 Like

If you are listing the functions you required before starting a test-driven approach, ensure you include pass so they are valid functions.

Then you can build the functions up with tests.

def function4later():
    “””A function I’ve not written yet.”””
    pass

But if you’ve not noticed you need to implement the code, I would question if you are comfortable with MorePy…

1 Like

I’ve actually been wondering why you reached the assertion error. I’d expect Python to choke on those empty function blocks on import.

And I was thinking the same thing as Graham: Have you done the first book, or another introduction to programming before? No offense, but if you didn’t see this, you’ll have a hard time moving on with LMPTHW.

1 Like

@florian I saw something similar with unittest this week. The test runner was showing all kinds of weird exceptions up the stack, but it was actually erroring because I had only included a method signature (no block) and it’s was bumming out at initialisation not the test runner.

1 Like

exactly, @florian! i guess i made a hasty decision to move right away to lmpthw from lpthw! i should practice much much more of lmpthw! everything seeems so easy when the book is on :upside_down_face: i shall discuss of lpthw only in this forum for now.

thank you @ulfen69 and @gpkesley for the suggestions and response.

Hey @vijayaavaas, you can post code more easily if you do this:

[code]
# put your code here
[/code]

Don’t forget the close / (slash) on [/code]. You can also do it this way:

```
# your code here
```

That’s a lot easier to view and post than a screenshot.

1 Like

thanks @zedshaw. i shall do that onward, i didn’t really know the style.

A free service run by Zed A. Shaw for learncodethehardway.org.