You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "eumiro (via GitHub)" <gi...@apache.org> on 2023/08/20 06:28:21 UTC
[GitHub] [airflow] eumiro opened a new pull request, #33546: Refactor: use tmp_path in core
eumiro opened a new pull request, #33546:
URL: https://github.com/apache/airflow/pull/33546
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] Taragolis commented on a diff in pull request #33546: Refactor: use tmp_path in core
Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on code in PR #33546:
URL: https://github.com/apache/airflow/pull/33546#discussion_r1299317031
##########
tests/core/test_configuration.py:
##########
@@ -549,17 +548,13 @@ def test_getsection(self):
assert test_conf.getsection("non_existent_section") is None
- def test_get_section_should_respect_cmd_env_variable(self):
- with tempfile.NamedTemporaryFile(delete=False) as cmd_file:
- cmd_file.write(b"#!/usr/bin/env bash\n")
- cmd_file.write(b"echo -n difficult_unpredictable_cat_password\n")
- cmd_file.flush()
- os.chmod(cmd_file.name, 0o0555)
- cmd_file.close()
-
- with mock.patch.dict("os.environ", {"AIRFLOW__WEBSERVER__SECRET_KEY_CMD": cmd_file.name}):
- content = conf.getsection("webserver")
- os.unlink(cmd_file.name)
+ def test_get_section_should_respect_cmd_env_variable(self, tmp_path):
+ path = tmp_path / "testfile.sh"
+ path.write_text("#!/usr/bin/env bash\necho -n difficult_unpredictable_cat_password\n")
+ path.chmod(0o0555)
Review Comment:
I'd rather keep original name of variable, because `path` it refers to something abstract, in opposite of `cmd_file ` which directly refers that it is file for command
##########
tests/core/test_configuration.py:
##########
@@ -549,17 +548,13 @@ def test_getsection(self):
assert test_conf.getsection("non_existent_section") is None
- def test_get_section_should_respect_cmd_env_variable(self):
- with tempfile.NamedTemporaryFile(delete=False) as cmd_file:
- cmd_file.write(b"#!/usr/bin/env bash\n")
- cmd_file.write(b"echo -n difficult_unpredictable_cat_password\n")
- cmd_file.flush()
- os.chmod(cmd_file.name, 0o0555)
- cmd_file.close()
-
- with mock.patch.dict("os.environ", {"AIRFLOW__WEBSERVER__SECRET_KEY_CMD": cmd_file.name}):
- content = conf.getsection("webserver")
- os.unlink(cmd_file.name)
+ def test_get_section_should_respect_cmd_env_variable(self, tmp_path):
+ path = tmp_path / "testfile.sh"
+ path.write_text("#!/usr/bin/env bash\necho -n difficult_unpredictable_cat_password\n")
+ path.chmod(0o0555)
+
+ with mock.patch.dict("os.environ", {"AIRFLOW__WEBSERVER__SECRET_KEY_CMD": os.fspath(path)}):
+ content = conf.getsection("webserver")
Review Comment:
This section also could be simplified by use [`monkeypatch`](https://docs.pytest.org/en/latest/how-to/monkeypatch.html) fixture
```suggestion
monkeypatch.setenv("AIRFLOW__WEBSERVER__SECRET_KEY_CMD", str(path))
content = conf.getsection("webserver")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] uranusjr merged pull request #33546: Refactor: use tmp_path in core
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr merged PR #33546:
URL: https://github.com/apache/airflow/pull/33546
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org