def test_negative_distance():
 with pytest.raises(ValueError):
  Distance([(-2), 3.1], u.kpc)
 with pytest.raises(ValueError):
  Distance([(-2), (-3.1)], u.kpc)
 with pytest.raises(ValueError):
  Distance((-2), u.kpc)
 d = Distance((-2), u.kpc, allow_negative=True)
 assert (d.value == (-2))

def test_negative_distance ( ) : with pytest . raises ( ValueError ) : Distance ( [ ( - 2 ) , 3.1 ] , u . kpc ) with pytest . raises ( ValueError ) : Distance ( [ ( - 2 ) , ( - 3.1 ) ] , u . kpc ) with pytest . raises ( ValueError ) : Distance ( ( - 2 ) , u . kpc ) d = Distance ( ( - 2 ) , u . kpc , allow_negative = True ) assert ( d . value == ( - 2 ) )
test optional kwarg allow_negative .