-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add documentation on how to do unit tests with web3.py #1324
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 👍 on this, however, wondering if you would be up to converting this to use pytest. If we're going to steer people towards anything I'd prefer it be that. I recognize unittest
is standard library and thus slightly less complex for example purposes, but I think there's value in demonstrating how this can be done using pytest with fixtures for a very clean testing environment.
If you're not familiar with pytest then potentially @njgheorghita or @kclowes could do this conversion.
happy to rewrite this in pytest, give me 10 minutes |
might be nice to actually write this as a file under the |
w00t One suggestion: it might be useful to log an event from the contract and check its correctness from the example test. |
right, I intended to do that originally when I added the event and then forgot about it, thanks |
006373e
to
e6bfd26
Compare
Okay I think this should be good for another review, I added code to check against an emitted event, and moved the code into the tests to be run with the test suite. Apologies if I put the file in the wrong place, I did my best guess and put it in the core/contracts directory. |
Will try to go over this and get it merged monday. Thanks for writing this up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for putting this together! This is awesome.
These docs aren't quite showing up the way that you intended. I added some comments on how to fix. You can run make docs
to build them locally.
Okay, made changes, thanks for the helpful hint on how to render the documentation locally - I think this should be good for another review |
@kclowes I pushed a commit to this updating the test structure a bit (mostly just personal preference). I'll leave it to you to do final review + merge. |
Sweet! 🚀 Thanks @relyt29 and @pipermerriam! |
What was wrong?
The python ecosystem in general is sorely in need of updated documentation of how to do unit testing of solidity contracts with python. Something along the lines of: https://github.com/ethereum/pyethereum/wiki/Using-pyethereum.tester
How was it fixed?
I wrote said example documentation.
Cute Animal Picture