From 03ca96373c0a68d0b9ae2da6ead823784d30626a Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Mon, 17 Mar 2025 18:11:08 +0530 Subject: [PATCH 1/4] fix(.github/workflows/main.yml): use different TZ to run CI tests --- .github/workflows/main.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30c94dbbe..6936600ba 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,12 @@ jobs: toxenv: docs - python-version: "3.13" toxenv: twinecheck + - python-version: "3.13" + toxenv: py + timezone: "Pacific/Auckland" + - python-version: "3.13" + toxenv: py + timezone: "Pacific/Fiji" steps: - uses: actions/checkout@v3 - name: 'Set up Python ${{ matrix.python-version }}' @@ -45,7 +51,14 @@ jobs: python -m pip install --upgrade pip pip install tox - name: Run tests - run: tox -e ${{ matrix.toxenv || 'py' }} + env: + TZ: ${{ matrix.timezone || 'UTC' }} + run: | + echo "Running tests with timezone: $TZ" + date + python -c "import datetime; print(f'Python datetime now: {datetime.datetime.now()}')" + python -c "import time; print(f'Python time localtime: {time.localtime()}')" + tox -e ${{ matrix.toxenv || 'py' }} - name: Upload coverage.xml to codecov uses: codecov/codecov-action@v5 with: From 57e09d697023db2d2f5be49ab9e6cd886b8ba407 Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Tue, 18 Mar 2025 01:12:59 +0530 Subject: [PATCH 2/4] fix(.github/workflows/main.yml): set env at runtime --- .github/workflows/main.yml | 12 +++++------- tox.ini | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6936600ba..a7e1e434d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,14 +51,12 @@ jobs: python -m pip install --upgrade pip pip install tox - name: Run tests - env: - TZ: ${{ matrix.timezone || 'UTC' }} run: | - echo "Running tests with timezone: $TZ" - date - python -c "import datetime; print(f'Python datetime now: {datetime.datetime.now()}')" - python -c "import time; print(f'Python time localtime: {time.localtime()}')" - tox -e ${{ matrix.toxenv || 'py' }} + TZ=${{ matrix.timezone || 'UTC' }} echo "Running tests with timezone: $TZ" + TZ=${{ matrix.timezone || 'UTC' }} date + TZ=${{ matrix.timezone || 'UTC' }} python -c "import datetime; print(f'Python datetime now: {datetime.datetime.now()}')" + TZ=${{ matrix.timezone || 'UTC' }} python -c "import time; print(f'Python time localtime: {time.localtime()}')" + TZ=${{ matrix.timezone || 'UTC' }} tox -e ${{ matrix.toxenv || 'py' }} - name: Upload coverage.xml to codecov uses: codecov/codecov-action@v5 with: diff --git a/tox.ini b/tox.ini index 312b4b3ae..fac54bd7a 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ deps = atheris; python_version < '3.12' commands = pytest --cov=dateparser --cov-report=xml {posargs: tests} +passenv = TZ [testenv:all] basepython = python3.13 From bcdac2d3a04f42e8dc307a415b7f7f060fee4239 Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Tue, 18 Mar 2025 02:07:13 +0530 Subject: [PATCH 3/4] fix(tests/test_search.py): fix failing tests for search_dates The search_dates default behavior is to use UTC timezone when no overridden setting is provided, hence the test must define the expectations in UTC timezone. --- tests/test_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_search.py b/tests/test_search.py index 252195503..cd838c2da 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -10,7 +10,7 @@ from dateparser_data.settings import default_parsers from tests import BaseTestCase -today = datetime.datetime.today() +today = datetime.datetime.now(tz=pytz.timezone("UTC")) class TestTranslateSearch(BaseTestCase): From 30c4bd38cdc13edc90022dd736c535ae395c94de Mon Sep 17 00:00:00 2001 From: Prashant Sharma Date: Tue, 18 Mar 2025 02:15:17 +0530 Subject: [PATCH 4/4] refactor(main.yml): remove debugging commands from CI logs --- .github/workflows/main.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a7e1e434d..52b871c3d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,9 +53,6 @@ jobs: - name: Run tests run: | TZ=${{ matrix.timezone || 'UTC' }} echo "Running tests with timezone: $TZ" - TZ=${{ matrix.timezone || 'UTC' }} date - TZ=${{ matrix.timezone || 'UTC' }} python -c "import datetime; print(f'Python datetime now: {datetime.datetime.now()}')" - TZ=${{ matrix.timezone || 'UTC' }} python -c "import time; print(f'Python time localtime: {time.localtime()}')" TZ=${{ matrix.timezone || 'UTC' }} tox -e ${{ matrix.toxenv || 'py' }} - name: Upload coverage.xml to codecov uses: codecov/codecov-action@v5