Skip to content
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

Merged
merged 4 commits into from Feb 19, 2016

Conversation

sandhujasmine
Copy link

Fixes GH 1418

Issue status

with pytest.raises(TypeError):
b = symbol('b', 'var * {x: string}')
Copy link
Member

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

Copy link
Author

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.

@llllllllll
Copy link
Member

How do you feel about testing the contents of the error strings?
something like:

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'
Copy link
Member

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.

Copy link
Author

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.

Copy link
Author

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:
   ...

@llllllllll

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], )

Copy link
Member

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

@llllllllll
Copy link
Member

Thank you for the test cases!

@sandhujasmine
Copy link
Author

@kwmsmith, @llllllllll

I was thinking to move exception tests for objects defined in collections module from test_interactive.py to test_collections.py, so moving:
test_sample_failures(), test_distinct_failures(), test_merge_failure()

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?

@llllllllll
Copy link
Member

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.

@kwmsmith
Copy link
Member

I was thinking to move exception tests for objects defined in collections module from test_interactive.py to test_collections.py

👍

@llllllllll
Copy link
Member

Thank you for these tests and cleaning up the existing ones!

llllllllll added a commit that referenced this pull request Feb 19, 2016
@llllllllll llllllllll merged commit a96d889 into blaze:master Feb 19, 2016
@sandhujasmine sandhujasmine deleted the input-validation-tests branch February 19, 2016 19:01
kwmsmith added a commit to kwmsmith/blaze that referenced this pull request Feb 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants