-
Notifications
You must be signed in to change notification settings - Fork 4
Add infrastucture for asserting a series of related values within a single test. #112
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
Conversation
9b982d4
to
6d7741d
Compare
In out desired use of the test suite is a requirement to allow writing a test that is the same assertion agianst a series of related values. As an example, imagine an operation on chunks and wishing to assert multiple sizes. This is obviously something to be extremely careful in promoting given it is in a fair amount of conflict with the notion of separate test cases, which experience says more "generally" leads to better outcomes. However, used judiciously this can be useful, and this is far better supported by a mechanism designed to support it: namely, that _all_ failures are reported up front rather than the first failing assertion cancelling the test block and the ending up in a fix-and-rerun cycle. Add a facility and associated assertion to the test support library that allows executing an operation and its assertion against a series of values, buffers any exceptions that occurs and enforce that either a no exception or all exception outcome is asserted by end of test. Include a mechanism to the support library so arbitrary objects can do checks and use this in multi-value assertions to ensure a result is validated by its containing case.
6d7741d
to
6f6ec2a
Compare
@@ -3,7 +3,6 @@ | |||
# | |||
# --- BEGIN_HEADER --- | |||
# | |||
# support - helper functions for unit testing |
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.
Nit-pick: these should stay to fit existing template. I've left them in when merging.
# -- END_HEADER --- | ||
# | ||
|
||
"""Infrastruture to support assertion over a range of values. |
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.
Nit-pick: one-line docstrings shouldn't add newline according to PEP8.
https://peps.python.org/pep-0008/#documentation-strings
class NoCasesError(AssertionError): | ||
pass | ||
|
||
class AssertOver: |
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.
Classes are slightly ashamed to stand around bare-naked, without even a docstring ;-)
@@ -0,0 +1,41 @@ | |||
import unittest |
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.
Missing license header. I'll add one here, but perhaps you could make a PR to do the same in the test_support, test_boolean and any other tests
modules where I've missed them?
return self._attempts.append(attempt_info) | ||
|
||
def to_check_callable(self): | ||
def raise_unless_consuted(): |
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'll fix this typo during merge and sprinkle in a few missing docstrings.
def record_attempt(self, attempt_info): | ||
return self._attempts.append(attempt_info) | ||
|
||
def to_check_callable(self): |
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.
This nested method without direct statements looks a bit strange to me, please at least document it for my sake.
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.
Ah no, it does return the function call ... but still it would like a docstring.
Merged through svn with a number of minor corrections as mentioned in review. |
No description provided.