Esempio n. 1
0
def test_get_stringifier():
    from pudb.var_view import InspectInfo, get_stringifier

    try:
        import numpy as np
    except ImportError:
        numpy_values = []
    else:
        numpy_values = [np.float32(5), np.zeros(5)]

    for value in [
            A,
            A2,
            A(),
            A2(),
            u"lól".encode("utf8"),
            u"lól",
            1233123,
        [u"lól".encode("utf8"), u"lól"],
    ] + numpy_values:
        for display_type in ["type", "repr", "str", "id"]:
            iinfo = InspectInfo()
            iinfo.display_type = display_type

            strifier = get_stringifier(iinfo)

            s = strifier(value)
            assert isinstance(s, text_type)
Esempio n. 2
0
def test_get_stringifier():
    try:
        import numpy as np
    except ImportError:
        numpy_values = []
    else:
        numpy_values = [np.float32(5), np.zeros(5)]

    for value in [
            A,
            A2,
            A(),
            A2(),
            "lól".encode(),
            "lól",
            1233123,
        ["lól".encode(), "lól"],
    ] + numpy_values:
        for display_type in STRINGIFIERS:
            iinfo = InspectInfo()
            iinfo.display_type = display_type

            strifier = get_stringifier(iinfo)

            s = strifier(value)
            assert isinstance(s, str)
Esempio n. 3
0
def test_get_stringifier():
    from pudb.var_view import InspectInfo, get_stringifier

    for value in [
            A, A2, A(), A2(), u"lól".encode('utf8'), u"lól",
            1233123, [u"lól".encode('utf8'), u"lól"],
            np.float32(5), np.zeros(5),
            ]:
        for display_type in ["type", "repr", "str"]:
            iinfo = InspectInfo()
            iinfo.display_type = display_type

            strifier = get_stringifier(iinfo)

            s = strifier(value)
            assert isinstance(s, text_type)