From dca9e2ee6eccf665dc7bc58c8b4925f6113af857 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Fri, 20 May 2022 20:10:37 -0400 Subject: [PATCH 1/4] Move imports to local to prevent pytest dependency --- asdf_astropy/testing/helpers.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/asdf_astropy/testing/helpers.py b/asdf_astropy/testing/helpers.py index 55ba829..b04059b 100644 --- a/asdf_astropy/testing/helpers.py +++ b/asdf_astropy/testing/helpers.py @@ -1,6 +1,3 @@ -from astropy import units -from astropy.coordinates import EarthLocation -from astropy.tests.helper import assert_quantity_allclose from numpy.testing import assert_array_equal @@ -11,6 +8,8 @@ def assert_earth_location_equal(a, b): def assert_representation_equal(a, b): + from astropy import units + __tracebackhide__ = True assert type(a) is type(b) @@ -41,6 +40,8 @@ def assert_frame_equal(a, b): def assert_spectral_coord_equal(a, b): + from astropy.tests.helper import assert_quantity_allclose + __tracebackhide__ = True assert type(a) is type(b) @@ -50,6 +51,8 @@ def assert_spectral_coord_equal(a, b): def assert_time_equal(a, b): + from astropy.coordinates import EarthLocation + assert a.format == b.format assert a.scale == b.scale From e1cb724eb3d022f9ace5672467c7332b46e35196 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Fri, 20 May 2022 20:39:45 -0400 Subject: [PATCH 2/4] Remove redundent helper file --- .../converters/coordinates/tests/helpers.py | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 asdf_astropy/converters/coordinates/tests/helpers.py diff --git a/asdf_astropy/converters/coordinates/tests/helpers.py b/asdf_astropy/converters/coordinates/tests/helpers.py deleted file mode 100644 index 130dab4..0000000 --- a/asdf_astropy/converters/coordinates/tests/helpers.py +++ /dev/null @@ -1,41 +0,0 @@ -import astropy.units as u -from astropy.tests.helper import assert_quantity_allclose - - -def assert_representation_equal(a, b): - __tracebackhide__ = True - - assert type(a) is type(b) - assert a.components == b.components - for component in a.components: - assert u.allclose(getattr(a, component), getattr(b, component)) - - -def assert_sky_coord_equal(a, b): - __tracebackhide__ = True - - assert a.is_equivalent_frame(b) - assert a.representation_type is b.representation_type - assert a.shape == b.shape - - assert_representation_equal(a.data, b.data) - - -def assert_frame_equal(a, b): - __tracebackhide__ = True - - assert type(a) is type(b) - - if a is None: - return - - assert_representation_equal(a.data, b.data) - - -def assert_spectral_coord_equal(a, b): - __tracebackhide__ = True - - assert type(a) is type(b) - assert_quantity_allclose(a.quantity, b.quantity) - assert_frame_equal(a.observer, b.observer) - assert_frame_equal(a.target, b.target) From 49e8e539bae0fe2ac38d607aa57a8e462d2fff28 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Fri, 20 May 2022 20:43:47 -0400 Subject: [PATCH 3/4] Modify tests actually use helper --- .../converters/coordinates/tests/test_spectral_coord.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/asdf_astropy/converters/coordinates/tests/test_spectral_coord.py b/asdf_astropy/converters/coordinates/tests/test_spectral_coord.py index 2fd0549..57de1c8 100644 --- a/asdf_astropy/converters/coordinates/tests/test_spectral_coord.py +++ b/asdf_astropy/converters/coordinates/tests/test_spectral_coord.py @@ -9,9 +9,8 @@ from astropy import units as u from astropy.coordinates import ICRS, Galactic, SpectralCoord from astropy.coordinates.spectral_coordinate import NoVelocityWarning -from astropy.tests.helper import assert_quantity_allclose -from asdf_astropy.testing.helpers import assert_frame_equal +from asdf_astropy.testing.helpers import assert_spectral_coord_equal def create_spectral_coords(): @@ -46,7 +45,4 @@ def test_serialization(coord, tmp_path): af.write_to(file_path) with asdf.open(file_path) as af: - assert type(af["coord"]) is type(coord) - assert_quantity_allclose(af["coord"].quantity, coord.quantity) - assert_frame_equal(af["coord"].observer, coord.observer) - assert_frame_equal(af["coord"].target, coord.target) + assert_spectral_coord_equal(af["coord"], coord) From 0fae8e1c0b90d0090322fe094440b50bd93b1d58 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Tue, 31 May 2022 10:09:42 -0400 Subject: [PATCH 4/4] Add 3.8 to Coverage --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1907b49..49ad149 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: Python 3.8 Tests python-version: "3.8" os: ubuntu-latest - toxenv: py38-test + toxenv: py38-test-cov - name: Mac OS Latest python-version: "3.9"