Example #1
0
def test_lowest_common_dshape_varlen_strings():
    assert lowest_common_dshape([String(10), String(11)]) == String(11)
    assert lowest_common_dshape([String(11), string]) == string
Example #2
0
def test_discover_bytes():
    x = b'abcdefg'
    assert discover(x) == String('A')
def test_funcproto_attrs():
    f = dshape('(int32, ?float64) -> {a: ?string}').measure
    assert f.restype == DataShape(Record([('a', Option(String()))]))
    assert f.argtypes == (DataShape(int32), DataShape(Option(float64)))
def test_unsupported_string_encoding():
    with pytest.raises(ValueError):
        String(1, 'asdfasdf')
 def test_string_from_CType_classmethod(self):
     assert CType.from_numpy_dtype(np.dtype('S7')) == String(7, 'A')
Example #6
0
def test_string():
    assert_dshape_equal(String(), String())
    assert_dshape_equal(String('U8'), String('U8'))
    assert_dshape_equal(String(1), String(1))
    assert_dshape_equal(String(1, 'U8'), String(1, 'U8'))

    with pytest.raises(AssertionError) as e:
        assert_dshape_equal(String('U8'), String('U16'))

    assert "{u}'U8' != {u}'U16'".format(u='u' if PY2 else '') in str(e.value)
    assert '_.encoding' in str(e.value)

    with pytest.raises(AssertionError) as e:
        assert_dshape_equal(String(1), String(2))
    assert '1 != 2' in str(e.value)
    assert '_.fixlen' in str(e.value)