Exemplo n.º 1
0
def test_jsonp_path_cached():
    class C(str):
        pass

    p = C("a/b")
    assert jsonp_path(p) == ["a", "b"]
    p._jsonp = False
    assert jsonp_path(p) == [p]
    assert p._jsonp == False
    p._jsonp = None
    assert jsonp_path(p) == ["a", "b"]
    assert p._jsonp == None
Exemplo n.º 2
0
def test_modifs_rename_fn(mod, exp, ser_method):
    renamer = lambda n: f"p.{n}"
    dep = mod()
    got = dep_renamed(dep, renamer)
    assert repr(got) == exp
    assert repr(ser_method(got)) == exp
    assert modifier_kws(got) == modifier_kws(dep)

    if getattr(dep, "_sideffected", None):
        # Check not just(!) `_repr` has changed.
        assert got._sideffected != dep._sideffected

    if getattr(dep, "_jsonp", None):
        assert got._jsonp != dep._jsonp
        assert got._jsonp == jsonp_path(got)
        assert got._jsonp == jsonp_path(str(got))
Exemplo n.º 3
0
def test_jsonp_path_None():
    with pytest.raises(TypeError):
        jsonp_path(None)
Exemplo n.º 4
0
def test_jsonp_path_with_spaces():
    assert jsonp_path("/ some ") == ["", " some "]
    assert jsonp_path("/ some /  ") == ["", " some ", "  "]

    assert jsonp_path(" some ") == [" some "]
    assert jsonp_path(" some /  ") == [" some ", "  "]
Exemplo n.º 5
0
def test_jsonp_path_folder():
    assert jsonp_path("/a/") == [""]
Exemplo n.º 6
0
def test_jsonp_path_regular():
    assert jsonp_path("/a") == ["", "a"]

    assert jsonp_path("/a/b") == ["", "a", "b"]
Exemplo n.º 7
0
def test_jsonp_path_root():
    assert jsonp_path("/") == [""]
Exemplo n.º 8
0
def test_jsonp_path_empty():
    assert jsonp_path("") == [""]
Exemplo n.º 9
0
def test_jsonp_path_massive(inp, exp):
    if isinstance(exp, Exception):
        with pytest.raises(type(exp), match=str(exp)):
            jsonp_path(inp)
    else:
        assert jsonp_path(inp) == exp