Пример #1
0
def test_from_altaz_parameters():
    usno = api.earth.topos('38.9215 N', '77.0669 W', elevation_m=92.0)
    p = usno(tt=api.T0)
    a = api.Angle(degrees=10.0)
    with assert_raises(ValueError, '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'):
        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')
Пример #2
0
def test_from_altaz_parameters(ts):
    e = api.load('de421.bsp')
    usno = e['earth'].topos('38.9215 N', '77.0669 W', elevation_m=92.0)
    jd = ts.tt(api.T0)
    p = usno.at(jd)
    a = api.Angle(degrees=10.0)
    with assert_raises(ValueError, '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'):
        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')
Пример #3
0
def test_tuple_error_raised():
    def fake_function():
        """ The decorator requires a docstring. """
    decorated_function = takes_julian_date(fake_function)
    tuple_argument = (2014, 1, 23)
    self = None
    with assert_raises(ValueError) as info:
        decorated_function(self, tuple_argument)
    assert 'Are you trying to pass in a tuple' in str(info.exception)
Пример #4
0
def test_iterating_over_raw_velocity():
    velocity = units.Velocity(au_per_d=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = velocity
Пример #5
0
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'):
        earth + mars
Пример #6
0
def test_sending_jd_that_is_not_a_julian_date():
    earth = api.load('de421.bsp')['earth']
    with assert_raises(ValueError, 'your "jd" argument is not a JulianDate: '):
        earth.at('blah')
Пример #7
0
def test_named_star_throws_valueerror():
    with assert_raises(ValueError, 'No star named foo known to skyfield'):
        api.NamedStar('foo')
Пример #8
0
def test_that_building_time_from_naive_datetime_raises_exception(ts):
    with assert_raises(ValueError) as info:
        ts.from_datetime(datetime(1973, 12, 29, 23, 59, 48))
    assert 'import timezone' in str(info.exception)
Пример #9
0
def test_raises3():
    with assert_raises(ValueError, 'correct message but wrong exception'):
        raise KeyError('correct message but wrong exception')
Пример #10
0
def test_building_JulianDate_from_naive_datetime_raises_exception():
    with assert_raises(ValueError) as info:
        JulianDate(utc=datetime(1973, 12, 29, 23, 59, 48))
    assert 'import timezone' in str(info.exception)
Пример #11
0
def test_build_url(load):
    url = 'ftp://ssd.jpl.nasa.gov/pub/eph/planets/bsp/de421.bsp'
    assert load.build_url('de421.bsp') == url
    with assert_raises(ValueError, 'know the URL'):
        load.build_url('unknown.kind.of.file')
Пример #12
0
def test_altaz_needs_topos(ts):
    e = api.load('de421.bsp')
    earth = e['earth']
    moon = e['moon']
    with assert_raises(ValueError, 'using a Topos instance'):
        earth.at(ts.utc(2016)).observe(moon).apparent().altaz()
def test_iterating_over_raw_angle():
    angle = Angle(degrees=4.5)
    with assert_raises(ValueError) as a:
        iter(angle)
    assert str(a.exception) == '''choose a specific Angle unit to iterate over
def test_iterating_over_raw_velocity():
    velocity = Velocity(au_per_d=1.234)
    with assert_raises(UnpackingError) as a:
        x, y, z = velocity
    assert str(a.exception) == '''\
def test_iterating_over_raw_measurement():
    distance = Distance(au=1.234)
    with assert_raises(UnpackingError) as a:
        x, y, z = distance
    assert str(a.exception) == '''\
Пример #16
0
def test_sending_jd_that_is_not_a_julian_date():
    with assert_raises(ValueError, 'your "jd" argument is not a JulianDate: '):
        api.earth('blah')
Пример #17
0
def test_from_altaz_needs_topos():
    p = positionlib.ICRF([0.0, 0.0, 0.0])
    with assert_raises(ValueError, 'to compute an altazimuth position'):
        p.from_altaz(alt_degrees=0, az_degrees=0)
Пример #18
0
def test_sending_jd_that_is_not_a_julian_date():
    return # TODO: turn this back on, using one of the new ts method calls
    earth = api.load('de421.bsp')['earth']
    with assert_raises(ValueError, 'your "jd" argument is not a JulianDate: '):
        earth.at('blah')
Пример #19
0
def test_iterating_over_raw_measurement():
    distance = units.Distance(au=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = distance
Пример #20
0
def test_raises1():
    with assert_raises(ValueError):
        raise ValueError('irrelevant message')
Пример #21
0
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'):
        earth + mars
Пример #22
0
def test_iterating_over_raw_velocity():
    velocity = units.Velocity(au_per_d=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = velocity
Пример #23
0
def test_raises2():
    with assert_raises(ValueError, 'correct message'):
        raise ValueError('correct message')
Пример #24
0
def test_sending_jd_that_is_not_a_julian_date():
    return  # TODO: turn this back on, using one of the new ts method calls
    earth = api.load('de421.bsp')['earth']
    with assert_raises(ValueError, 'your "jd" argument is not a JulianDate: '):
        earth.at('blah')
Пример #25
0
def test_raises4():
    with assert_raises(ValueError, 'one message'):
        raise ValueError('another message')
Пример #26
0
def test_sending_jd_that_is_not_a_julian_date():
    with assert_raises(ValueError, 'your "jd" argument is not a JulianDate: '):
        api.earth('blah')
Пример #27
0
def test_from_altaz_needs_topos():
    p = positionlib.ICRF([0.0, 0.0, 0.0])
    with assert_raises(ValueError, 'the orientation of the horizon'):
        p.from_altaz(alt_degrees=0, az_degrees=0)
Пример #28
0
def test_altaz_needs_topos(ts):
    e = api.load('de421.bsp')
    earth = e['earth']
    moon = e['moon']
    with assert_raises(ValueError, 'from a specific Earth location'):
        earth.at(ts.utc(2016)).observe(moon).apparent().altaz()
Пример #29
0
def test_building_JulianDate_from_naive_datetime_raises_exception():
    with assert_raises(ValueError) as info:
        JulianDate(utc=datetime(1973, 12, 29, 23, 59, 48))
    assert "import timezone" in str(info.exception)
Пример #30
0
def test_raises4():
    with assert_raises(ValueError, 'one message'):
        raise ValueError('another message')
Пример #31
0
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'):
        earth - usno
Пример #32
0
def test_raises1():
    with assert_raises(ValueError):
        raise ValueError('irrelevant message')
Пример #33
0
def test_iterating_over_raw_measurement():
    distance = units.Distance(au=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = distance
Пример #34
0
def test_raises2():
    with assert_raises(ValueError, 'correct message'):
        raise ValueError('correct message')
Пример #35
0
def test_that_building_time_from_naive_datetime_raises_exception(ts):
    with assert_raises(ValueError) as info:
        ts.utc(datetime(1973, 12, 29, 23, 59, 48))
    assert 'import timezone' in str(info.exception)
Пример #36
0
def test_raises3():
    with assert_raises(ValueError, 'correct message but wrong exception'):
        raise KeyError('correct message but wrong exception')
Пример #37
0
def test_from_altaz_needs_topos():
    p = positionlib.ICRS([0.0, 0.0, 0.0])
    with assert_raises(ValueError, 'the orientation of the horizon'):
        p.from_altaz(alt_degrees=0, az_degrees=0)
Пример #38
0
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'):
        earth - usno
Пример #39
0
def test_named_star_throws_valueerror():
    with assert_raises(ValueError, 'No star named foo known to skyfield'):
        api.NamedStar('foo')
Пример #40
0
def test_non_builtin_timescale_tries_to_load_finals2000A_all(load):
    save_file(load, 'finals2000A.all', b'invalid data')
    with assert_raises(IndexError):
        load.timescale(builtin=False)