def test_ensure_on_supplied(self): data = '1' with ShouldRaise(TypeError('Cannot use if_supplied() as target')): store(data, if_supplied(target).x, 'y')
def test_if_supplied_required_falsy(self): data = Namespace(x=None) with ShouldRaise(NotPresent(None)): load(data, required(if_supplied(source.x)))
def test_if_supplied_str(self): compare(str(if_supplied(source.x)), expected='if_supplied(source.x)')
def test_if_supplied_falsy(self): data = Namespace(x=None) compare(load(data, if_supplied(source.x)), expected=NotPresent(None))
def test_if_supplied_string(self): data = Namespace(x='1') compare(load(data, if_supplied('x')), expected='1')
def test_if_supplied_truthy(self): data = Namespace(x='1') compare(load(data, if_supplied(source.x)), expected='1')