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

Refactor assert x == y into self.assertEqual(x, y) #12

Open
sobolevn opened this issue Feb 13, 2022 · 4 comments · May be fixed by #13
Open

Refactor assert x == y into self.assertEqual(x, y) #12

sobolevn opened this issue Feb 13, 2022 · 4 comments · May be fixed by #13

Comments

@sobolevn
Copy link

I think the second option is better because:

  1. It does not get removed in -O mode
  2. It has much cleaner error message
@isidentical
Copy link
Owner

Are there any tests that use assert x == y in an unittest? I've never seen such code, but if you have any examples feel free to add an implementation for that.

@sobolevn
Copy link
Author

CPython has lots of assert tests with unittest.
Examples:

I think that this is an error, but I would not push this change there 🙂
I will send a PR with this feature somewhere this week, though 👍

@isidentical
Copy link
Owner

Ah, TIL. Would gladly accept a PR about it.

@sobolevn
Copy link
Author

I think that there are some important limitations to this rule:

  1. It should be limited to ast.[Async]FunctionDef scope inside ast.ClassDef
  2. We must be sure that it is a test function. For now, I am going to detect a test as "a method" with test prefix or postfix
  3. We must be sure that self argument exists

sobolevn added a commit to sobolevn/teyit that referenced this issue Feb 28, 2022
@sobolevn sobolevn linked a pull request Feb 28, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants