-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
[AIRFLOW-5241] Make test class names consistent by starting with Test #5847
[AIRFLOW-5241] Make test class names consistent by starting with Test #5847
Conversation
@ashb tagging you here because I believe you were doing some preliminary work for testing with Pytest. |
Can we also include linting on the test name? |
Exactly my thought @milton0825 . Just wonder what will be the best tool ? Regexp? Some ast parsing? |
Quick Google search learned me that nosetests has a @potiuk why was this PR closed? |
Sorry. Wrote that on the phone :) . Autocomplete in Polish works great when I type in English. It was all by mistake -> I clicked wrong button. |
For pre-commit hook: tests' file names we can use |
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.
LGTM
Change looks good, but is probably worth adding some sort of lint-check as discussed. |
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.
LGTM
Would also be great to make the filenames consistent, looking at you here tests/core.py
😀
Will do in another PR |
@BasPH when you come to rename tests/core.py, be aware that one or two other test files do |
@potiuk @Fokko @ashb had a think about it. Pytest requires test class names to start with |
Am I right in thinking that if the name is wrong then py-test will simply "ignore" the tests and not run it? That's not great, and we ran in to that problem in the past with the file name of nose tests, so I think a custom script might still be needed? |
Pytest docs regarding test classes:
I indeed read that Pytest will ignore tests not prefixed with |
In the past we add tests but because of bad naming they never ran, which is almost worse than not adding tests. |
Okay, isn't that up to the reviewer to correct? If we were to implement some name enforcement utility, we'd have to first fetch all class definitions from all tests file, check if they start with |
It is, but the less load we can place on the reviewers the better. If it's possible without lots of effort anyway. Everything in |
Ok, some more examples:
All utility classes for the tests. What rule would you apply to such class names to determine if they're test classes or not and should start with I'd say if there's an |
Probably a lot of work then, you are right. |
Okay. I rebased and resolved all conflicts the gcp package created. Good to merge? |
Make all test class names consistent by starting with Test
Make sure you have checked all steps below.
Jira
Description
I believe there are many ways to improve the current test suite. To start, I suggest to make the test class naming consistent by always starting with "Test".
Some insights:
grep -r "class" . | grep "TestCase" | wc -l
)There is no convention AFAIK in unittest for test classes (only tests themselves -> start with "test"). I suggest to make all test classes start with "Test" because I know there is some work being done on moving to Pytest, which discovers test classes starting with "Test" (link).
Tests
This PR involved renaming all non Test* named test classes.
I had to make one other change in tests/utils/test_helpers.py which contained two classes TestHelpers and HelpersTest, both testing exactly the same things, even with identical test names. I merged the two classes and merged the tests with identical names.
Commits
Documentation
Code Quality
flake8