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
TST: Add input validation tests #1420
TST: Add input validation tests #1420
Conversation
Fixes GH 1418
with pytest.raises(TypeError): | ||
b = symbol('b', 'var * {x: string}') |
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.
We should move this out of the context manager. As a general rule context invariant code should not be placed in the context manager when possible because then readers need to know if the context manager affects the code in any way. In this particular case, if symbol
raises a TypeError
then this test will pass when it shouldn't
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.
Indeed - thanks @llllllllll
Fixed and tested.
How do you feel about testing the contents of the error strings? with pytest.raises(Error) as e:
...
assert '...' in str(e.value)
assert str(e.value) == '...' We might want to test that the error message includes the correct column or incorrect value. |
@@ -108,13 +108,21 @@ def test_join_option_types(): | |||
assert join(b, a, 'x').dshape == dshape('var * {x: int}') | |||
|
|||
|
|||
def test_join_mismatched_schema(): | |||
def test_join_exceptions(): | |||
'mismatched schema; no shared fields' |
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.
Can we use triple quoted strings for docstrings. It took me a second to realize this was the docstring.
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.
How do you feel about testing the contents of the error strings?
I feel good about it - I had added but wasn't sure if it was overkill. It's easy to add so I'll update.
Can we use triple quoted strings for docstrings
Yes, will fix.
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.
How do you feel about testing the contents of the error strings?
something like:with pytest.raises(Error) as e: ...
Instead of doing an exact match would it suffice to check substring? This will keep it concise and not require string formatting. I don't think exact match buys us much more once we've validated the correct exception was raised.
with pytest.raises(TypeError) as excinfo:
join(a, b, 'x')
assert 'Schemata of joining columns do not match,' in str(excinfo.value)
The exact message for this exception is:
'Schemata of joining columns do not match,' ' no promotion found for %s=%s and %s=%s' % ( on_left[n], left_types[n], on_right[n], right_types[n], )
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.
that is fine, we might want to just check that the expected column names appear in the string
Thank you for the test cases! |
I was thinking to move exception tests for objects defined in collections module from test_interactive.py to test_collections.py, so moving: I added the last two here but seems like the general convention is for tests for a module to be in associated test_.py What do you think? |
Moving the tests sounds good. Keeping tests organized makes it easier for developers to find the place to add new tests which encourages better testing. |
👍 |
Thank you for these tests and cleaning up the existing ones! |
TST: Add input validation tests
Fixes GH 1418
Issue status