jimmysong / programmingbitcoin

Repository for the book
Other
1.75k stars 656 forks source link

Chapter 3, Exercise 3 self.assertEqual() error #262

Open michaelalangill opened 1 year ago

michaelalangill commented 1 year ago

When saving the ecc.py file with the code given in the "answers" file for this exercise, I get a "NotImplementedError". When I adjust the code to say return p1+p2==p3, the test passes. The exercise is to make the test pass, which I was able to do without looking at the answers. That said, when I checked myself, I thought the answer looked better (especially considering that delicious self.assertEqual()). Mine works, the 'answer' doesn't. Why?

aniketambore commented 1 year ago

The reason for encountering a NotImplementedError is likely due to either not removing the raise NotImplementedError line from the test_add method in the ECCTest class, or because your python interpreter session is still using an outdated version of the code even after you have made changes and saved the updated file.

To resolve the issue, ensure that you have properly removed the mentioned line, or restart the python interpreter session to run the test without errors.

The testcase will pass without any error as expected.

>>> import ecc                   
>>> from helper import run
>>> run(ecc.ECCTest('test_add'))
.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
>>>