Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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')
Ejemplo n.º 7
0
def test_named_star_throws_valueerror():
    with assert_raises(ValueError, 'No star named foo known to skyfield'):
        api.NamedStar('foo')
Ejemplo n.º 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)
Ejemplo n.º 9
0
def test_raises3():
    with assert_raises(ValueError, 'correct message but wrong exception'):
        raise KeyError('correct message but wrong exception')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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) == '''\
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 19
0
def test_iterating_over_raw_measurement():
    distance = units.Distance(au=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = distance
Ejemplo n.º 20
0
def test_raises1():
    with assert_raises(ValueError):
        raise ValueError('irrelevant message')
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 23
0
def test_raises2():
    with assert_raises(ValueError, 'correct message'):
        raise ValueError('correct message')
Ejemplo n.º 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')
Ejemplo n.º 25
0
def test_raises4():
    with assert_raises(ValueError, 'one message'):
        raise ValueError('another message')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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()
Ejemplo n.º 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)
Ejemplo n.º 30
0
def test_raises4():
    with assert_raises(ValueError, 'one message'):
        raise ValueError('another message')
Ejemplo n.º 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
Ejemplo n.º 32
0
def test_raises1():
    with assert_raises(ValueError):
        raise ValueError('irrelevant message')
Ejemplo n.º 33
0
def test_iterating_over_raw_measurement():
    distance = units.Distance(au=1.234)
    with assert_raises(units.UnpackingError):
        x, y, z = distance
Ejemplo n.º 34
0
def test_raises2():
    with assert_raises(ValueError, 'correct message'):
        raise ValueError('correct message')
Ejemplo n.º 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)
Ejemplo n.º 36
0
def test_raises3():
    with assert_raises(ValueError, 'correct message but wrong exception'):
        raise KeyError('correct message but wrong exception')
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 39
0
def test_named_star_throws_valueerror():
    with assert_raises(ValueError, 'No star named foo known to skyfield'):
        api.NamedStar('foo')
Ejemplo n.º 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)