コード例 #1
0
ファイル: test_dbm_extra.py プロジェクト: Qointum/pypy
def test_null():
    db = dbm.open("test", "c")
    db["1"] = "a\x00b"
    db.close()

    db = dbm.open("test", "r")
    assert db["1"] == "a\x00b"
    db.close()
コード例 #2
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_null():
    db = dbm.open('test', 'c')
    db['1'] = 'a\x00b'
    db.close()

    db = dbm.open('test', 'r')
    assert db['1'] == 'a\x00b'
    db.close()
コード例 #3
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_multiple_sets():
    path = str(udir.join('test_dbm_extra.test_multiple_sets'))
    d = dbm.open(path, 'c')
    d['xyz'] = '12'
    d['xyz'] = '3'
    d['xyz'] = '546'
    assert dict(d) == {'xyz': '546'}
    assert d['xyz'] == '546'
コード例 #4
0
ファイル: test_dbm_extra.py プロジェクト: Qointum/pypy
def test_multiple_sets():
    path = str(udir.join("test_dbm_extra.test_multiple_sets"))
    d = dbm.open(path, "c")
    d["xyz"] = "12"
    d["xyz"] = "3"
    d["xyz"] = "546"
    assert dict(d) == {"xyz": "546"}
    assert d["xyz"] == "546"
コード例 #5
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_key_with_empty_value():
    # this test fails on CPython too (at least on tannit), and the
    # case shows up when gdbm is not installed and test_anydbm.py
    # falls back dbm.
    py.test.skip("test may fail on CPython too")
    path = str(udir.join('test_dbm_extra.test_key_with_empty_value'))
    d = dbm.open(path, 'c')
    assert 'key_with_empty_value' not in d
    d['key_with_empty_value'] = ''
    assert 'key_with_empty_value' in d
    assert d['key_with_empty_value'] == ''
    d.close()
コード例 #6
0
ファイル: test_dbm_extra.py プロジェクト: Qointum/pypy
def test_key_with_empty_value():
    # this test fails on CPython too (at least on tannit), and the
    # case shows up when gdbm is not installed and test_anydbm.py
    # falls back dbm.
    py.test.skip("test may fail on CPython too")
    path = str(udir.join("test_dbm_extra.test_key_with_empty_value"))
    d = dbm.open(path, "c")
    assert "key_with_empty_value" not in d
    d["key_with_empty_value"] = ""
    assert "key_with_empty_value" in d
    assert d["key_with_empty_value"] == ""
    d.close()
コード例 #7
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_nonstring():
    path = str(udir.join('test_dbm_extra.test_nonstring'))
    d = dbm.open(path, 'c')
    py.test.raises(TypeError, "d[123] = 'xyz'")
    py.test.raises(TypeError, "d['xyz'] = 123")
    py.test.raises(TypeError, "d['xyz'] = None")
    py.test.raises(TypeError, "del d[123]")
    py.test.raises(TypeError, "d[123]")
    py.test.raises(TypeError, "123 in d")
    py.test.raises(TypeError, "d.has_key(123)")
    py.test.raises(TypeError, "d.setdefault(123, 'xyz')")
    py.test.raises(TypeError, "d.setdefault('xyz', 123)")
    py.test.raises(TypeError, "d.get(123)")
    assert dict(d) == {}
    d.setdefault('xyz', '123')
    assert dict(d) == {'xyz': '123'}
    d.close()
コード例 #8
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_delitem():
    path = str(udir.join('test_dbm_extra.test_delitem'))
    d = dbm.open(path, 'c')
    py.test.raises(KeyError, "del d['xyz']")
コード例 #9
0
ファイル: test_dbm_extra.py プロジェクト: sota/pypy-old
def test_get():
    path = str(udir.join('test_dbm_extra.test_get'))
    d = dbm.open(path, 'c')
    x = d.get("42")
    assert x is None
    d.close()
コード例 #10
0
ファイル: test_dbm_extra.py プロジェクト: tools-env/mesapy
def test_unicode_filename():
    path = str(udir) + os.sep + u'test_dbm_extra.test_unicode_filename'
    d = dbm.open(path, 'c')
    d.close()