def test_ref_converts_to_leaf_value_specified_by_relative_path(example_path): example_path.monkey.here_is_a_reference = "foo.bar.baz" example_path.monkey.lover = sentinel.monkeylover r = ref(rel.here_is_a_reference) assert r._convert(example_path.monkey.lover._match()[0]) == sentinel.foobarbaz
def test_ref_only_accepts_objects_that_convert_to_paths(): with pytest.raises(TypeError) as err: ref(sentinel.path) assert str(err.value) == "Argument 'ref' must be a path."
def test_ref_converts_to_leaf_value_specified_by_path(example_path): example_path.here_is_a_reference = "foo.bar.baz" r = ref(example_path.here_is_a_reference) assert r._convert(Context()) == sentinel.foobarbaz
def test_ref_converts_to_leaf_value_specified_by_path_wildcarded_at_end(example_path): example_path.monkey.here_is_a_reference = "foo.bar.baz" r = ref(example_path.monkey['%i']) assert r._convert(Context(i='here_is_a_reference')) == sentinel.foobarbaz