blinkseb commented on code in PR #30243:
URL: https://github.com/apache/airflow/pull/30243#discussion_r1146041004
##########
tests/dag_processing/test_manager.py:
##########
@@ -438,17 +439,23 @@ def test_add_new_file_to_parsing_queue(
)
@conf_vars({("scheduler", "file_parsing_sort_mode"): "modified_time"})
+ @mock.patch("airflow.settings.TIMEZONE", timezone.utc)
@mock.patch("zipfile.is_zipfile", return_value=True)
@mock.patch("airflow.utils.file.might_contain_dag", return_value=True)
@mock.patch("airflow.utils.file.find_path_from_directory",
return_value=True)
@mock.patch("airflow.utils.file.os.path.isfile", return_value=True)
@mock.patch("airflow.utils.file.os.path.getmtime")
def test_recently_modified_file_is_parsed_with_mtime_mode(
- self, mock_getmtime, mock_isfile, mock_find_path,
mock_might_contain_dag, mock_zipfile
+ self, mock_getmtime, mock_isfile, mock_find_path,
mock_might_contain_dag, mock_zipfile, monkeypatch
):
"""
Test recently updated files are processed even if
min_file_process_interval is not reached
"""
+ # ensure platform timezone does not affect the modified time value
+ monkeypatch.setenv("TZ", "Europe/Paris")
+ # propagate new timezone to C routines
+ time.tzset()
Review Comment:
great idea. I've added a new fixture and applied it to all _mtime_ tests.
Instead of adding a `skipif` mark, I just call `tzset` if it exists.
According the the Windows documentation of `localtime_s` [0] (which is used
internally by `fromtimestamp` on Windows if no timezone is set)
> localtime_s corrects for the local time zone if the user first sets the
global environment variable TZ. When TZ is set, three other environment
variables (_timezone, _daylight, and _tzname) are automatically set as well.
[0]
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/localtime-s-localtime32-s-localtime64-s?view=msvc-170
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]