This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 894d7104d1 Use temporary directories for tests remote aws loggers
(#25762)
894d7104d1 is described below
commit 894d7104d1e7f30e20e0f6e5cffb67345c35821d
Author: Andrey Anshin <[email protected]>
AuthorDate: Sat Aug 20 02:39:01 2022 +0400
Use temporary directories for tests remote aws loggers (#25762)
* Use temporary directories for tests remote aws loggers
* replace tmpdir_factory by tmp_path_factory
---
.../2020-01-01T00_00_00+00_00/1.log | 0
tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py | 4 ++--
tests/providers/amazon/aws/log/test_s3_task_handler.py | 6 +++---
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git
a/local/log/location/dag_for_testing_cloudwatch_task_handler/task_for_testing_cloudwatch_log_handler/2020-01-01T00_00_00+00_00/1.log
b/local/log/location/dag_for_testing_cloudwatch_task_handler/task_for_testing_cloudwatch_log_handler/2020-01-01T00_00_00+00_00/1.log
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py
b/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py
index 8b23218c8c..a193799530 100644
--- a/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py
+++ b/tests/providers/amazon/aws/log/test_cloudwatch_task_handler.py
@@ -55,10 +55,10 @@ def logmock():
class TestCloudwatchTaskHandler:
@conf_vars({('logging', 'remote_log_conn_id'): 'aws_default'})
@pytest.fixture(autouse=True)
- def setup(self, create_log_template):
+ def setup(self, create_log_template, tmp_path_factory):
self.remote_log_group = 'log_group_name'
self.region_name = 'us-west-2'
- self.local_log_location = 'local/log/location'
+ self.local_log_location =
str(tmp_path_factory.mktemp("local-cloudwatch-log-location"))
create_log_template('{dag_id}/{task_id}/{execution_date}/{try_number}.log')
self.cloudwatch_task_handler = CloudwatchTaskHandler(
self.local_log_location,
diff --git a/tests/providers/amazon/aws/log/test_s3_task_handler.py
b/tests/providers/amazon/aws/log/test_s3_task_handler.py
index 958ded562e..caea35a57d 100644
--- a/tests/providers/amazon/aws/log/test_s3_task_handler.py
+++ b/tests/providers/amazon/aws/log/test_s3_task_handler.py
@@ -51,11 +51,11 @@ def s3mock():
class TestS3TaskHandler:
@conf_vars({('logging', 'remote_log_conn_id'): 'aws_default'})
@pytest.fixture(autouse=True)
- def setup(self, create_log_template):
+ def setup(self, create_log_template, tmp_path_factory):
self.remote_log_base = 's3://bucket/remote/log/location'
self.remote_log_location = 's3://bucket/remote/log/location/1.log'
self.remote_log_key = 'remote/log/location/1.log'
- self.local_log_location = 'local/log/location'
+ self.local_log_location =
str(tmp_path_factory.mktemp("local-s3-log-location"))
create_log_template('{try_number}.log')
self.s3_task_handler = S3TaskHandler(self.local_log_location,
self.remote_log_base)
# Vivfy the hook now with the config override
@@ -144,7 +144,7 @@ class TestS3TaskHandler:
self.s3_task_handler.set_context(self.ti)
assert self.s3_task_handler.upload_on_close
-
mock_open.assert_called_once_with(os.path.abspath('local/log/location/1.log'),
'w')
+
mock_open.assert_called_once_with(os.path.join(self.local_log_location,
'1.log'), 'w')
mock_open().write.assert_not_called()
def test_read(self):