1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662
|
From: Antonio Valentino <antonio.valentino@tiscali.it>
Date: Sun, 14 Aug 2022 20:20:29 +0200
Subject: Use pytest instead of assay
Forwarded: not-needed
---
skyfield/tests/test_against_horizons.py | 2 ++
skyfield/tests/test_against_novas.py | 4 ++++
skyfield/tests/test_almanac_searches.py | 4 ++--
skyfield/tests/test_api.py | 21 +++++++++---------
skyfield/tests/test_elementslib.py | 14 +++++++-----
skyfield/tests/test_io.py | 7 +++---
skyfield/tests/test_positions.py | 6 ++---
skyfield/tests/test_strs_and_reprs.py | 2 ++
skyfield/tests/test_timelib.py | 39 ++++++++++++++++++++++-----------
skyfield/tests/test_topos.py | 24 ++++++++++++++++----
skyfield/tests/test_units.py | 28 +++++++++++------------
skyfield/tests/test_vectors.py | 6 ++---
12 files changed, 99 insertions(+), 58 deletions(-)
diff --git a/skyfield/tests/test_against_horizons.py b/skyfield/tests/test_against_horizons.py
index da3ecfc..264dd33 100644
--- a/skyfield/tests/test_against_horizons.py
+++ b/skyfield/tests/test_against_horizons.py
@@ -6,6 +6,7 @@ from skyfield import api, framelib
from skyfield.api import Topos
from skyfield.constants import AU_M
from skyfield.trigonometry import position_angle_of
+import pytest
def _data_path(filename):
return os.path.join(os.path.dirname(__file__), 'data', filename)
@@ -15,6 +16,7 @@ arcsecond = 1.0 / 60.0 / 60.0
ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0
meter = 1.0 / AU_M
+@pytest.fixture
def ts():
yield api.load.timescale()
diff --git a/skyfield/tests/test_against_novas.py b/skyfield/tests/test_against_novas.py
index 340eaa8..2cd1cc1 100644
--- a/skyfield/tests/test_against_novas.py
+++ b/skyfield/tests/test_against_novas.py
@@ -8,6 +8,7 @@ from skyfield.constants import AU_KM, AU_M
from skyfield.data import hipparcos
from skyfield.functions import BytesIO, length_of
from .fixes import low_precision_ERA
+import pytest
OLD_AU_KM = 149597870.691
OLD_AU = AU_KM / OLD_AU_KM
@@ -17,6 +18,7 @@ arcsecond = 1.0 / 60.0 / 60.0
ra_arcsecond = 24.0 / 360.0 / 60.0 / 60.0
meter = 1.0 / AU_M
+@pytest.fixture
def ts():
yield load.timescale()
@@ -26,9 +28,11 @@ def compare(value, expected_value, epsilon):
else:
assert abs(value - expected_value) <= epsilon
+@pytest.fixture
def de405():
yield load('de405.bsp')
+@pytest.fixture
def earth():
eph = load('de405.bsp')
yield eph[399]
diff --git a/skyfield/tests/test_almanac_searches.py b/skyfield/tests/test_almanac_searches.py
index ee3d717..017329e 100644
--- a/skyfield/tests/test_almanac_searches.py
+++ b/skyfield/tests/test_almanac_searches.py
@@ -2,7 +2,7 @@
import numpy as np
-from assay import assert_raises
+import pytest
from skyfield.api import load
from skyfield.searchlib import find_discrete, find_maxima
@@ -30,7 +30,7 @@ def test_exception_if_step_days_is_missing():
def f(t):
return t.J > 0.0
t0, t1 = make_t()
- with assert_raises(AttributeError, 'missing a "step_days" attribute'):
+ with pytest.raises(AttributeError, match='missing a "step_days" attribute'):
find_discrete(t0, t1, f, epsilon)
def test_find_discrete_that_finds_nothing():
diff --git a/skyfield/tests/test_api.py b/skyfield/tests/test_api.py
index e3eebb3..83dfccd 100644
--- a/skyfield/tests/test_api.py
+++ b/skyfield/tests/test_api.py
@@ -1,17 +1,18 @@
"""Tests of the Skyfield `api` module and user-facing exceptions."""
import numpy as np
-from assay import assert_raises
+import pytest
from skyfield import api, positionlib
from skyfield.api import Topos
from skyfield.errors import EphemerisRangeError
+@pytest.fixture
def ts():
yield api.load.timescale()
def test_sending_jd_that_is_not_a_julian_date():
earth = api.load('de421.bsp')['earth']
- with assert_raises(ValueError, r"please provide the at\(\) method"
+ with pytest.raises(ValueError, match=r"please provide the at\(\) method"
" with a Time instance as its argument,"
" instead of the value 'blah'"):
earth.at('blah')
@@ -34,7 +35,7 @@ def test_astrometric_position_does_not_allow_altaz(ts):
e = api.load('de421.bsp')
o = e['earth'] + api.wgs84.latlon(36.7138, -112.2169)
a = o.at(ts.utc(2014, 2, 9, 14, 50)).observe(e['mars'])
- with assert_raises(ValueError, 'it is not useful to call .altaz'):
+ with pytest.raises(ValueError, match='it is not useful to call .altaz'):
a.altaz()
def test_ephemeris_contains_method(ts):
@@ -51,10 +52,10 @@ def test_exception_raised_for_dates_outside_ephemeris(ts):
message = (
'ephemeris segment only covers dates 1899-07-29 through 2053-10-09'
)
- with assert_raises(EphemerisRangeError, message) as a:
+ with pytest.raises(EphemerisRangeError, match=message) as a:
eph['earth'].at(ts.tt(4096))
- e = a.exception
+ e = a.value
assert e.args == (message,)
assert e.start_time.tdb == 2414864.5
assert e.end_time.tdb == 2471184.5
@@ -114,7 +115,7 @@ def test_hadec_needs_a_longitude(ts):
earth = e['earth']
moon = e['moon']
apparent = earth.at(ts.utc(2016)).observe(moon)
- with assert_raises(ValueError, 'from a specific latitude and longitude'):
+ with pytest.raises(ValueError, match='from a specific latitude and longitude'):
apparent.hadec()
def test_altaz_needs_topos(ts):
@@ -122,12 +123,12 @@ def test_altaz_needs_topos(ts):
earth = e['earth']
moon = e['moon']
apparent = earth.at(ts.utc(2016)).observe(moon).apparent()
- with assert_raises(ValueError, 'from a specific latitude and longitude'):
+ with pytest.raises(ValueError, match='from a specific latitude and longitude'):
apparent.altaz()
def test_from_altaz_needs_topos():
p = positionlib.ICRF([0.0, 0.0, 0.0])
- with assert_raises(ValueError, 'to compute altitude and azimuth'):
+ with pytest.raises(ValueError, match='to compute altitude and azimuth'):
p.from_altaz(alt_degrees=0, az_degrees=0)
def test_from_altaz_parameters(ts):
@@ -136,9 +137,9 @@ def test_from_altaz_parameters(ts):
p = usno.at(t)
a = api.Angle(degrees=10.0)
d = api.Distance(au=0.234)
- with assert_raises(ValueError, 'the alt= parameter with an Angle'):
+ with pytest.raises(ValueError, match='the alt= parameter with an Angle'):
p.from_altaz(alt='Bad value', alt_degrees=0, az_degrees=0)
- with assert_raises(ValueError, 'the az= parameter with an Angle'):
+ with pytest.raises(ValueError, match='the az= parameter with an Angle'):
p.from_altaz(az='Bad value', alt_degrees=0, az_degrees=0)
p.from_altaz(alt=a, alt_degrees='bad', az_degrees=0)
p.from_altaz(az=a, alt_degrees=0, az_degrees='bad')
diff --git a/skyfield/tests/test_elementslib.py b/skyfield/tests/test_elementslib.py
index 27747b0..f2c10f3 100644
--- a/skyfield/tests/test_elementslib.py
+++ b/skyfield/tests/test_elementslib.py
@@ -11,7 +11,9 @@ from skyfield.elementslib import (
from skyfield.keplerlib import ele_to_vec
from numpy import array, pi, ndarray, float64, repeat, seterr, inf, linspace
import os
+import pytest
+@pytest.fixture
def ts():
yield load.timescale()
@@ -20,12 +22,12 @@ def _data_path(filename):
ECLIPTIC = inertial_frames['ECLIPJ2000']
-ephem = load_file(_data_path('de430-2015-03-02.bsp'))
-jup_ephem = load_file(_data_path('jup310-2015-03-02.bsp'))
-io = jup_ephem['io']
-moon = ephem['moon']
-earth = ephem['earth']
-sun = ephem['sun']
+# ephem = load_file(_data_path('de430-2015-03-02.bsp'))
+# jup_ephem = load_file(_data_path('jup310-2015-03-02.bsp'))
+# io = jup_ephem['io']
+# moon = ephem['moon']
+# earth = ephem['earth']
+# sun = ephem['sun']
seterr(all='raise')
diff --git a/skyfield/tests/test_io.py b/skyfield/tests/test_io.py
index 209cd7c..412236e 100644
--- a/skyfield/tests/test_io.py
+++ b/skyfield/tests/test_io.py
@@ -14,7 +14,7 @@ try:
except ImportError:
from mock import patch
-from assay import assert_raises
+import pytest
from skyfield import api
leap_second_text = (
@@ -23,6 +23,7 @@ leap_second_text = (
b' 41499.0 1 7 1972 11\n'
)
+@pytest.fixture
def load():
path = tempfile.mkdtemp()
try:
@@ -49,7 +50,7 @@ def fake_download(load, filename, content):
def test_build_url(load):
url = 'https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/de421.bsp'
assert load.build_url('de421.bsp') == url
- with assert_raises(ValueError, 'know the URL'):
+ with pytest.raises(ValueError, match='know the URL'):
load.build_url('unknown.kind.of.file')
def test_open_in_main_directory(load):
@@ -98,7 +99,7 @@ def test_non_builtin_timescale_prefers_USNO_files(load):
def test_non_builtin_timescale_tries_to_load_finals2000A_all(load):
save_file(load, 'finals2000A.all', b'invalid data')
- with assert_raises(IndexError):
+ with pytest.raises(IndexError):
load.timescale(builtin=False)
def test_close_of_ephemeris(load):
diff --git a/skyfield/tests/test_positions.py b/skyfield/tests/test_positions.py
index ca387bc..be2d860 100644
--- a/skyfield/tests/test_positions.py
+++ b/skyfield/tests/test_positions.py
@@ -8,7 +8,7 @@ from skyfield.positionlib import Geocentric, ICRF, ITRF_to_GCRS2, _GIGAPARSEC_AU
from skyfield.starlib import Star
from .fixes import low_precision_ERA
-from assay import assert_raises
+import pytest
def test_subtraction():
p0 = ICRF((10,20,30), (40,50,60), center=0, target=499)
@@ -21,7 +21,7 @@ def test_subtraction():
assert tuple(p.velocity.au_per_d) == (36, 45, 54)
p1.center = 1
- with assert_raises(ValueError):
+ with pytest.raises(ValueError):
p0 - p1
def test_separation_from_on_scalar():
@@ -396,7 +396,7 @@ def test_astropy_conversion():
assert a.obstime.fits == '2022-01-03T00:00:00.000'
p = ICRF(r, t=t, center=3)
- with assert_raises(NotImplementedError):
+ with pytest.raises(NotImplementedError):
a = p.to_skycoord()
def test_old_position_attribute():
diff --git a/skyfield/tests/test_strs_and_reprs.py b/skyfield/tests/test_strs_and_reprs.py
index 8a4768e..eabf658 100644
--- a/skyfield/tests/test_strs_and_reprs.py
+++ b/skyfield/tests/test_strs_and_reprs.py
@@ -1,6 +1,7 @@
import textwrap
from ..api import Topos, load, wgs84
from ..sgp4lib import EarthSatellite
+import pytest
lines = [
'ISS (ZARYA) ',
@@ -11,6 +12,7 @@ lines = [
def dedent(s):
return textwrap.dedent(s.rstrip())
+@pytest.fixture
def eph():
yield load('de421.bsp')
diff --git a/skyfield/tests/test_timelib.py b/skyfield/tests/test_timelib.py
index 7c9a0f8..bd3b86f 100644
--- a/skyfield/tests/test_timelib.py
+++ b/skyfield/tests/test_timelib.py
@@ -2,7 +2,7 @@ import datetime as dt_module
import numbers
import numpy as np
import sys
-from assay import assert_raises
+import pytest
from pytz import timezone
from numpy import array, inf
from skyfield import api
@@ -17,9 +17,9 @@ from datetime import datetime
one_second = 1.0 / DAY_S
epsilon = one_second * 42.0e-6 # 20.1e-6 is theoretical best precision
-continuous_timescale = ['tai', 'tt', 'tdb', 'ut1']
-time_scale_name = ['utc', 'tai', 'tt', 'tdb', 'ut1']
-time_value = [(1973, 1, 18, 1, 35, 37.5), 2441700.56640625]
+_continuous_timescale = ['tai', 'tt', 'tdb', 'ut1']
+_time_scale_name = ['utc', 'tai', 'tt', 'tdb', 'ut1']
+_time_value = [(1973, 1, 18, 1, 35, 37.5), 2441700.56640625]
def test_timescale_with_old_fashioned_leap_second_table():
# Skyfield no longer uses the awkward old-style leap second table,
@@ -39,6 +39,7 @@ def test_timescale_with_old_fashioned_leap_second_table():
t = ts.tai(1970, 1, 1)
assert t.utc == (1969, 12, 31, 23, 59, 50)
+@pytest.fixture
def ts():
yield api.load.timescale()
@@ -87,6 +88,9 @@ def all_kinds_of_time_array(ts):
yield Time(ts, jd, fraction)
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('continuous_timescale,time_value',
+ zip(_continuous_timescale, _time_value))
def test_time_creation_methods(ts, continuous_timescale, time_value):
method = getattr(ts, continuous_timescale)
if isinstance(time_value, tuple):
@@ -141,23 +145,25 @@ def test_days_overflow_correctly(ts):
def test_sequence_behaviors_of_time_that_is_not_array(ts):
t = ts.utc(2023, 4, 2)
- with assert_raises(TypeError):
+ with pytest.raises(TypeError):
for item in t:
pass
# The specific exception TypeError in the following case makes
# Pandas inference.is_sequence() happy.
- with assert_raises(TypeError):
+ with pytest.raises(TypeError):
len(t)
def test_time_can_be_indexed(ts):
for t in all_kinds_of_time_array(ts):
t[0]
+@pytest.mark.parametrize('time_scale_name', _time_scale_name)
def test_is_time_iterable(ts, time_scale_name):
t = getattr(ts, time_scale_name)(2020, 9, (25, 26))
for item in t:
pass
+@pytest.mark.skip('internet connection not available')
def test_strftime_on_prehistoric_dates(ts_either):
if sys.version_info <= (3,):
return # Python 2 time.strftime() complains about negative years
@@ -218,7 +224,7 @@ def test_tt_seconds_preserve_10_decimal_places_in_calendar_seconds(ts):
assert c[:5] == (2020, 6, 7, 2, 2)
assert '%.10f' % c[5] == '12.0123456789'
-time_params_with_array = [
+_time_params_with_array = [
((2018, 2019, 2020), 3, 25, 13, 1, 10),
(2018, (3, 4, 5), 25, 13, 1, 10),
(2018, 3, (25, 26, 27), 13, 1, 10),
@@ -227,6 +233,9 @@ time_params_with_array = [
(2018, 3, 25, 13, 1, (10, 11, 12)),
]
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('time_scale_name,time_params_with_array',
+ zip(_time_scale_name, _time_params_with_array))
def test_time_creation_with_arrays(ts, time_scale_name, time_params_with_array):
print(time_scale_name)
t = getattr(ts, time_scale_name)(*time_params_with_array)
@@ -240,9 +249,9 @@ def test_timescale_utc_method_with_array_inside(ts):
assert t.tai[i] == ts.utc(1973, 12, 29, 23, 59, second).tai
def test_that_building_time_from_naive_datetime_raises_exception(ts):
- with assert_raises(ValueError) as info:
+ with pytest.raises(ValueError) as info:
ts.from_datetime(datetime(1973, 12, 29, 23, 59, 48))
- assert 'import timezone' in str(info.exception)
+ assert 'import timezone' in str(info.value)
def test_building_time_from_single_utc_datetime(ts):
t = ts.from_datetime(datetime(1973, 12, 29, 23, 59, 48, tzinfo=utc))
@@ -346,6 +355,7 @@ def test_slicing_time(ts):
assert (t.ut1[2:4] == t24.ut1).all()
assert (t.delta_t[2:4] == t24.delta_t).all()
+@pytest.mark.skip('internet connection not available')
def test_early_utc(ts_either):
ts = ts_either
t = ts.utc(1915, 12, 2, 3, 4, 5.6786786)
@@ -404,22 +414,22 @@ def test_utc_datetime_exception_for_negative_year():
ts = api.load.timescale()
ts.julian_calendar_cutoff = GREGORIAN_START
t = ts.utc(-1, 1, 1)
- with assert_raises(ValueError, 'negative years like the year -1'):
+ with pytest.raises(ValueError, match='negative years like the year -1'):
t.utc_datetime()
t = ts.utc([-2, -3, -1], 1, 1)
- with assert_raises(ValueError, 'negative years like the year -2'):
+ with pytest.raises(ValueError, match='negative years like the year -2'):
t.utc_datetime()
def test_utc_datetime_exception_for_julian_leap_day():
ts = api.load.timescale()
ts.julian_calendar_cutoff = GREGORIAN_START
t = ts.utc(700, 2, 29)
- with assert_raises(ValueError, 'Julian leap days like 700 February 29'):
+ with pytest.raises(ValueError, match='Julian leap days like 700 February 29'):
t.utc_datetime()
t = ts.utc(700, 2, [28, 29, 30])
- with assert_raises(ValueError, 'Julian leap days like 700 February 29'):
+ with pytest.raises(ValueError, match='Julian leap days like 700 February 29'):
t.utc_datetime()
def test_iso_of_decimal_that_rounds_up(ts):
@@ -693,6 +703,7 @@ def test_raw_julian_gregorian_cutover():
2299159, 2299160, 2299161, 2299162,
]
+@pytest.mark.parametrize('time_scale_name', _time_scale_name)
def test_constructor_julian_gregorian_cutover(time_scale_name):
if sys.version_info <= (3,):
return # Python 2 time.strftime() complains about the year 1582
@@ -724,6 +735,7 @@ def test_constructor_julian_gregorian_cutover(time_scale_name):
assert jd(1752, 9, 2) == 2361220.5
assert jd(1752, 9, 14) == 2361221.5
+@pytest.mark.parametrize('time_scale_name', _time_scale_name)
def test_calendar_tuple_julian_gregorian_cutover(time_scale_name):
if sys.version_info <= (3,):
return # Python 2 time.strftime() complains about the year 1582
@@ -755,6 +767,7 @@ def test_calendar_tuple_julian_gregorian_cutover(time_scale_name):
assert ymd(2361220.5) == (1752, 9, 2)
assert ymd(2361221.5) == (1752, 9, 14)
+@pytest.mark.parametrize('time_scale_name', _time_scale_name)
def test_strftime_julian_gregorian_cutover(time_scale_name):
if sys.version_info <= (3,):
return # Python 2 time.strftime() complains about the year 1582
diff --git a/skyfield/tests/test_topos.py b/skyfield/tests/test_topos.py
index d292edb..7fc1e34 100644
--- a/skyfield/tests/test_topos.py
+++ b/skyfield/tests/test_topos.py
@@ -1,4 +1,4 @@
-from assay import assert_raises
+import pytest
from numpy import abs, arange, sqrt
from skyfield import constants
@@ -7,16 +7,19 @@ from skyfield.functions import length_of
from skyfield.positionlib import Apparent, Barycentric
from skyfield.toposlib import ITRSPosition, iers2010
-angle = (-15, 15, 35, 45)
+_angle = (-15, 15, 35, 45)
+@pytest.fixture
def ts():
yield load.timescale()
-def t():
+def _t_gen():
ts = load.timescale()
yield ts.utc(2020, 11, 3, 17, 5)
yield ts.utc(2020, 11, 3, 17, [5, 5])
+_t = list(_t_gen())
+
def test_polar_radius():
assert round(wgs84.polar_radius.km) == 6357
@@ -144,14 +147,18 @@ def test_polar_motion_when_computing_altaz_coordinates(ts):
assert abs(alt.degrees - novas_alt) < 1.9e-9
assert abs(az.degrees - novas_az) < 1.3e-7
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('angle', _angle)
def test_subpoint_with_wrong_center(ts, angle):
t = ts.utc(2020, 12, 31)
p = Barycentric([0,0,0], t=t)
- with assert_raises(ValueError, 'you can only calculate a geographic'
+ with pytest.raises(ValueError, match='you can only calculate a geographic'
' position from a position which is geocentric'
' .center=399., but this position has a center of 0'):
wgs84.subpoint(p)
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('angle', _angle)
def test_iers2010_subpoint(ts, angle):
t = ts.utc(2018, 1, 19, 14, 37, 55)
# An elevation of 0 is more difficult for the routine's accuracy
@@ -168,6 +175,8 @@ def test_iers2010_subpoint(ts, angle):
error_mas = 60.0 * 60.0 * 1000.0 * error_degrees
assert error_mas < 0.1
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('angle', _angle)
def test_wgs84_subpoint(ts, angle):
t = ts.utc(2018, 1, 19, 14, 37, 55)
# An elevation of 0 is more difficult for the routine's accuracy
@@ -184,6 +193,7 @@ def test_wgs84_subpoint(ts, angle):
error_mas = 60.0 * 60.0 * 1000.0 * error_degrees
assert error_mas < 0.1
+@pytest.mark.parametrize('ts', [ts], indirect=True)
def test_wgs84_subpoint_at_pole(ts):
# The `height` previously suffered from very low precision at the pole.
t = ts.utc(2023, 4, 7, 12, 44)
@@ -196,6 +206,8 @@ def test_wgs84_subpoint_at_pole(ts):
g = wgs84.geographic_position_of(p)
assert abs(g.elevation.m - 10.0) < micrometer
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('angle', _angle)
def test_wgs84_round_trip_with_polar_motion(ts, angle):
t = ts.utc(2018, 1, 19, 14, 37, 55)
ts.polar_motion_table = [0.0], [0.003483], [0.358609]
@@ -212,6 +224,8 @@ def test_wgs84_round_trip_with_polar_motion(ts, angle):
error_mas = 60.0 * 60.0 * 1000.0 * error_degrees
assert error_mas < 0.1
+@pytest.mark.parametrize('t', _t)
+@pytest.mark.parametrize('angle', _angle)
def test_latlon_and_subpoint_methods(t, angle):
g = wgs84.latlon(angle, 2 * angle, elevation_m=1234.0)
pos = g.at(t)
@@ -253,6 +267,8 @@ def test_latlon_and_subpoint_methods(t, angle):
assert g2.elevation.m == 0.0
check_itrs(g2.itrs_xyz.m, 1234.0)
+@pytest.mark.parametrize('ts', [ts], indirect=True)
+@pytest.mark.parametrize('angle', _angle)
def test_deprecated_position_subpoint_method(ts, angle):
t = ts.utc(2018, 1, 19, 14, 37, 55)
top = iers2010.latlon(angle, angle, elevation_m=0.0)
diff --git a/skyfield/tests/test_units.py b/skyfield/tests/test_units.py
index 7a418e4..fb5ce55 100644
--- a/skyfield/tests/test_units.py
+++ b/skyfield/tests/test_units.py
@@ -1,6 +1,6 @@
"""Tests of whether units behave."""
-from assay import assert_raises
+import pytest
from numpy import array, nan
from skyfield.units import (
Angle, Distance, Velocity, UnpackingError, WrongUnitError,
@@ -61,7 +61,7 @@ def test_angle_array_strs():
assert str(h) == '3 values from 00h 30m 00.00s to -13h 00m 00.00s'
assert str(d) == '''3 values from 07deg 30' 00.0" to -195deg 00' 00.0"'''
- with assert_raises(WrongUnitError):
+ with pytest.raises(WrongUnitError):
h.dstr()
d.hstr()
@@ -142,13 +142,13 @@ to use this Distance, ask for its value in a particular unit:
distance.km
distance.m'''
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
x, y, z = distance
- assert str(a.exception) == expect
+ assert str(a.value) == expect
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
distance[0]
- assert str(a.exception) == expect
+ assert str(a.value) == expect
velocity = Velocity(1.234)
expect = '''\
@@ -158,13 +158,13 @@ to use this Velocity, ask for its value in a particular unit:
velocity.km_per_s
velocity.m_per_s'''
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
x, y, z = velocity
- assert str(a.exception) == expect
+ assert str(a.value) == expect
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
velocity[0]
- assert str(a.exception) == expect
+ assert str(a.value) == expect
angle = Angle(radians=1.234)
expect = '''\
@@ -174,13 +174,13 @@ to use this Angle, ask for its value in a particular unit:
angle.hours
angle.radians'''
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
x, y, z = angle
- assert str(a.exception) == expect
+ assert str(a.value) == expect
- with assert_raises(UnpackingError) as a:
+ with pytest.raises(UnpackingError) as a:
angle[0]
- assert str(a.exception) == expect
+ assert str(a.value) == expect
def test_constructors_accept_plain_lists():
Distance(au=[1,2,3])
diff --git a/skyfield/tests/test_vectors.py b/skyfield/tests/test_vectors.py
index 1fca5ec..db67c0d 100644
--- a/skyfield/tests/test_vectors.py
+++ b/skyfield/tests/test_vectors.py
@@ -1,6 +1,6 @@
# Test the behavior of all combinations of vector.
-from assay import assert_raises
+import pytest
from skyfield.api import Topos, load
from skyfield.positionlib import Geocentric
@@ -8,14 +8,14 @@ def test_bad_addition():
planets = load('de421.bsp')
earth = planets['earth']
mars = planets['mars']
- with assert_raises(ValueError, 'the center where the other vector starts'):
+ with pytest.raises(ValueError, match='the center where the other vector starts'):
earth + mars
def test_bad_subtraction():
planets = load('de421.bsp')
earth = planets['earth']
usno = Topos('38.9215 N', '77.0669 W', elevation_m=92.0)
- with assert_raises(ValueError, 'if they both start at the same center'):
+ with pytest.raises(ValueError, match='if they both start at the same center'):
earth - usno
def test_chebyshev_subtraction():
|