Skip to content

Commit

Permalink
Add Python regression test for #249
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherRabotin committed Jun 9, 2024
1 parent cb55ba9 commit bc8d4d8
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 18 deletions.
76 changes: 60 additions & 16 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,31 +113,75 @@ jobs:
pip install pytest
pytest
macos:
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-14
target: aarch64
macos-13: # last available x86_64 macos runner
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
lfs: true

- uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: "3.11"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
args: --release --out dist --find-interpreter -F python
target: x86_64
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: anise-py

- name: Upload wheels
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: wheels-macos-${{ matrix.platform.target }}
path: dist
name: wheels
path: anise-py/dist

- name: pytest
shell: bash
env:
RUST_BACKTRACE: 1
run: |
set -e
pip install anise --find-links anise-py/dist --force-reinstall
pip install pytest
pytest
macos-14: # first available aarch64 macos runner
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
lfs: true

- uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: aarch64
args: --release --out dist --find-interpreter
sccache: 'true'
working-directory: anise-py

- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: anise-py/dist

- name: pytest
shell: bash
env:
RUST_BACKTRACE: 1
run: |
set -e
pip install anise --find-links anise-py/dist --force-reinstall
pip install pytest
pytest
sdist:
runs-on: ubuntu-latest
Expand All @@ -158,7 +202,7 @@ jobs:
name: Release
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs: [linux, windows, macos, sdist]
needs: [linux, windows, macos-13, macos-14, sdist]
steps:
- uses: actions/download-artifact@v3
with:
Expand Down
10 changes: 8 additions & 2 deletions tests/python/test_epoch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from hifitime import Duration, Epoch, EpochError, ParsingError, TimeSeries, Unit
from hifitime import Duration, Epoch, EpochError, ParsingError, TimeScale, TimeSeries, Unit
from datetime import datetime
import pickle

Expand Down Expand Up @@ -81,4 +81,10 @@ def test_exceptions():
except EpochError as e:
print(f"caught {e}")
else:
raise AssertionError("failed to catch epoch error")
raise AssertionError("failed to catch epoch error")

def test_regression_gh249():
e = Epoch.init_from_gregorian(year=2022, month=3, day=1, hour=1, minute=1, second=59, nanos=1, time_scale=TimeScale.GPST)
assert e.strftime("%Y %m %d %H %M %S %f %T") == "2022 03 01 01 01 59 000000001 GPST"
e = Epoch.init_from_gregorian(year=2022, month=3, day=1, hour=1, minute=1, second=59, nanos=1, time_scale=TimeScale.UTC)
assert e.strftime("%Y %m %d %H %M %S %f %T") == "2022 03 01 01 01 59 000000001 UTC"

0 comments on commit bc8d4d8

Please sign in to comment.