def value(rhs: RightHandSideValueType) -> RightHandSideValue: if isinstance(rhs, RightHandSideValue): return rhs if Null.accepts_rhs(rhs): return Null() if String.accepts_rhs(rhs): return String(rhs) if Number.accepts_rhs(rhs): return Number(rhs) if DateTime.accepts_rhs(rhs): return DateTime(rhs) if Boolean.accepts_rhs(rhs): return Boolean(rhs) if Collection.accepts_rhs(rhs): return Collection(rhs) if Mapping.accepts_rhs(rhs): return Mapping(rhs) raise TypeError('Right-hand side value type is not supported: {}'.format( type(rhs).__name__))
def test_null_should_not_match_truthy_lhs(lhs): assert Null().match(lhs) is False
def test_null_should_match_falsey_lhs(lhs): assert Null().match(lhs) is True
def test_null_should_not_equal_to_truthy_lhs(lhs): assert Null().equal(lhs) is False
def test_null_rhs_should_match_none_lhs(): assert Null().match(None) is True
def test_null_rhs_should_equal_to_none_lhs(): assert Null().equal(None) is True