-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(observers): Correct Offset namedtuple name. (#3)
If we lie about the the name of the namedtuple, it isn't pickleable. Also, the start of a test-suite
- Loading branch information
1 parent
ea10f69
commit 47569d2
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: ch_ephem-tests | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
run-tests: | ||
|
||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.12"] | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install pip dependencies | ||
run: pip install -e .[test] | ||
|
||
- name: Run tests | ||
run: pytest -v . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Test ch_ephem.observers""" | ||
|
||
import pickle | ||
|
||
from ch_ephem import observers | ||
|
||
|
||
def test_pickle_observers(): | ||
"""Observers should be picklable.""" | ||
|
||
# These are all small powers of two to | ||
# avoid floating-point shennanigans | ||
test = observers.Observer(lat=1, lon=2, alt=4, rot=8, roll=16, offset=(32, 64, 128)) | ||
|
||
pickled = pickle.dumps(test) | ||
assert pickled is not None | ||
|
||
result = pickle.loads(pickled) | ||
|
||
assert result.latitude == 1 | ||
assert result.longitude == 2 | ||
assert result.altitude == 4 | ||
assert result.rotation == 8 | ||
assert result.roll == 16 | ||
assert result.offset.x == 32 | ||
assert result.offset.y == 64 | ||
assert result.offset.z == 128 | ||
|
||
repickled = pickle.dumps(result) | ||
|
||
assert pickled == repickled |