[AIRFLOW-5732] Add unit test for the version command#6401
Conversation
There's no unit test for the `airflow version` command for now. This PR adds a unit test for that command so as to avoid an accidental regression.
Codecov Report
@@ Coverage Diff @@
## master #6401 +/- ##
==========================================
- Coverage 80.61% 80.31% -0.31%
==========================================
Files 626 626
Lines 36217 36217
==========================================
- Hits 29196 29086 -110
- Misses 7021 7131 +110
Continue to review full report at Codecov.
|
| os.remove('variables2.json') | ||
| os.remove('variables3.json') | ||
|
|
||
| def test_cli_version(self): |
There was a problem hiding this comment.
I'm afraid this test is in the wrong place. tests/cli/test_cli.py is a better file.
I am also afraid of sys.stdout mocking. Python has a special mechanism for this.
https://github.com/sekikn/incubator-airflow/blob/9ff0c4f79a009618215a2af60418f664168456f4/tests/cli/test_cli.py#L344-L352
There was a problem hiding this comment.
Thanks for the comment @mik-laj!
I'm afraid this test is in the wrong place. tests/cli/test_cli.py is a better file.
The reason that I added the new test to test/core.py was it has many cli-related tests in its TestCli class. I have no objection to move the new test into tests/cli/test_cli.py, but is there any criteria to put a new cli-related test into it (or should we basically use tests/cli/test_cli.py in the future)?
I am also afraid of sys.stdout mocking. Python has a special mechanism for this.
I didn't use contextlib.redirect_stdout because of concern for the compatibility with Python2, but I've just noticed we're going to drop it on the master branch. I'll address it on another PR, thanks :)
Make sure you have checked all steps below.
Jira
Description
This PR adds a unit test for the
airflow versioncommand.Tests
test_cli_version in tests/core.py
Commits
Documentation