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

Improve type validation tests #134

Merged
merged 12 commits into from Apr 3, 2020
Merged

Conversation

fornellas
Copy link
Contributor

Add more thorough testing to type checking:

  • tests/lib_testslide.py added with more cases variation.
  • StrictMock & mock_callable() had type checking tests added for all use cases (module function / instance/class/static methods).
    • Found an issue with type checking for class methods.

Along the way:

  • Fixed type checking for class methods.
  • Fixed type checking error message.
    • It was an aggregation of TypeError messages which would not match the existing error.
    • It now shows each error on a separate line:
TypeError: Call with incompatible argument types:
  'arg1': type of arg1 must be str; got int instead
  'arg2': type of arg2 must be str; got int instead
  'kwarg1': type of kwarg1 must be str; got int instead
  'kwarg2': type of kwarg2 must be str; got int instead"
  • Moved all common stuff to testslide/lib .
  • Integrated common logic for extracting methods from mocks into _wrap_signature_and_type_validation, so StrictMock & mock_callable now works with other mocks.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Apr 2, 2020
@fornellas fornellas added this to the Type Checking milestone Apr 2, 2020
@deathowl deathowl merged commit 09bd9dc into master Apr 3, 2020
@fornellas fornellas deleted the improve_type_validation_tests branch April 6, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants