Draft
Conversation
Collaborator
Can you write some developer-facing prose/howto docs for this feature? I will read and comment on those. Skimming the current diff, it's not obvious to me how this is meant to be used. I'd rather comment on UX of the API than implementation details. :) |
Owner
Author
|
I'll write some docs when I have time, yeah. But quick version is: class MyTests(unittest.TestCase):
def test_mything(self):
logs = logs_for_pyunit(self) # start capturing logs
do_my_thing() # run normal test code
# Ok now you can make assertions about logs:
# 1. I expect a ZeroDivisionError to be logged.
assert len(logs.remove_expected_tracebacks(ZeroDivisionError)) == 1
# 2. I expect a my_action action:
assert logs.messages[0]["action_type"] == "my_action"
# Or something like
[action] = logs.parse()
# Now I have a eliot.parse.WrittenAction to play with |
Owner
Author
|
If you have a custom JSON encoding class: def test_mytest(self):
# Check that encodes using custom JSON encoder (and then decodes with default json.loads):
logs = logs_for_pyunit(self, encode=CustomEncoder().encode)
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current testing API:
eliot.parse.Loggerglobal state, which means it's hard to do things like additionally logging all messages via py.test plugin.New design:
eliot.parsefor validation of messages (will likely port some of the utility methods fromeliot.testing.)Any thoughts? @exarkun @thedrow @jonathanj