-
Notifications
You must be signed in to change notification settings - Fork 55
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
raise value error from the constructor level #290
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
53afe4a
raise value error from the constructor level
EricLiclair 73ea05d
adding test cases and formatting the error message
EricLiclair faadb6a
fixinf typo
EricLiclair 494b615
raise value error from the constructor level
EricLiclair 90fc4cd
Merge branch 'master' of https://github.com/EricLiclair/TestSlide
EricLiclair File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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 have a few notes around the tests:
assetRaises
as context manager such that the code to test is written in a more "natural" form and please assert that the content of the exception matches your expectations (example below). NOTE This applies to all the assertionstestValueError
would be failing we would have 9 assertions (as for now) to verify and this makes it very hard to scaleA user of the testing framework should not be using "private" (underscore-prefixed methods/classes) components of the framework. Please create some tests triggering the case that you are covering by this PR.
Example
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.
Hi, thanks for your valuable response and yes I do appreciate it. I tried to figure out a way to address the original issue. I believe I understood what needs to be done, but I am kind of stuck as to which all matchers need to be updated. Previously I was changing the private methods
_AndMatcher
,_OrMatcher
and_XorMatcher
. But after your last response I kind of believe that those are not where update needs to be done.Also I tried figuring out what all cases might trigger the error I was trying to raise.
I'm stuck.
I need your help, if you could guide me, where and what all to be updated.
What I have from the past responses:
isinstance()
.ValueError
with an intuitiveerro message
.assertRaise
as context manager.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 have a small step back and check what the issue reports.
It does mention that if we would be using
AnyInstanceOf(not_a_type)
it would throw aTypeError
becausenot_a_type
is not a type.While it would be better to have a more explicit exception matching that the
AnyInstanceOf
matcher was not properly configured.Now, the comments provided so far were a mixture between python-ism and having tests that help us to ensure that what is fixed today does not get broken/removed tomorrow without a direct intent.
What would I expect to see?
Essentially,
AnyInstanceOf
is used when you want to match parameters into mocked methods.An example of a "correct" usage would be
but now what would happen if I would have a test like
It would fail with a very odd exception like
which makes little sense. Would not it be better to have had something like (fully made up exception here)
When I mentioned
I meant to create a test like
test_triggering
that shows how the user would "mis-use" the matchers and that they would now receive theValuleError
exception.