예제 #1
0
def test_body_kwargs():
    name = "2 Pallas"
    symbol = u"\u26b4"
    k = 1.41e10 * u.m**3 / u.s**2
    pallas2 = bodies.Body(None, k, name, symbol)
    assert pallas2.kwargs == {}
    pallas2 = bodies.Body(None, k, name, symbol, custom='data')
    assert 'custom' in pallas2.kwargs
예제 #2
0
def test_body_printing_has_name_and_symbol():
    name = "2 Pallas"
    symbol = u"\u26b4"
    k = 1.41e10 * u.m**3 / u.s**2
    pallas2 = bodies.Body(None, k, name, symbol)
    assert name in str(pallas2)
    assert symbol in str(pallas2)
예제 #3
0
def test_body_has_k_given_in_constructor():
    k = 3.98e5 * u.km**3 / u.s**2
    earth = bodies.Body(None, k, "")
    assert earth.k == k
예제 #4
0
def test_body_constructor_raises_valueerror_if_k_units_not_correct():
    wrong_k = 4902.8 * u.kg
    with pytest.raises(u.UnitsError) as excinfo:
        moon = bodies.Body(wrong_k)
    assert ("UnitsError: Argument 'k' to function '__init__' must be in units convertible to 'm3 / s2'."
            in excinfo.exconly())