示例#1
0
def test_shelf_in(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert "key" in shelf
        assert "notkey" not in shelf
        shelf.close()
示例#2
0
def test_shelf_in(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert "key" in shelf
        assert "notkey" not in shelf
        shelf.close()
示例#3
0
def test_tell(method):
    test_data = "some even more different test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        assert file.tell() == 0
        file.write(test_data)
        assert file.tell() == len(test_data)
        file.close()
示例#4
0
def test_tell(method):
    test_data = "some even more different test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        assert file.tell() == 0
        file.write(test_data)
        assert file.tell() == len(test_data)
        file.close()
示例#5
0
def test_shelf_get(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        assert shelf.get("key") == "value"
        assert shelf.get("notkey") is None
        assert shelf.get("notkey", "notvalue") == "notvalue"
        shelf.close()
示例#6
0
def test_shelf_get(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        assert shelf.get("key") == "value"
        assert shelf.get("notkey") is None
        assert shelf.get("notkey", "notvalue") == "notvalue"
        shelf.close()
示例#7
0
def test_read(method):
    test_data = "Some more test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        assert test_data == file.read()
        file.close()
示例#8
0
def test_read(method):
    test_data = "Some more test data"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass) 
        assert test_data == file.read()
        file.close()
示例#9
0
def test_seek(method):
    test_data = "1234567890"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        file.seek(-2, 2)
        assert file.read() == test_data[-2:]
        file.close()
示例#10
0
def test_seek(method):
    test_data = "1234567890"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write(test_data)
        file.close()

        file = method(test_file, test_pass)
        file.seek(-2, 2)
        assert file.read() == test_data[-2:]
        file.close()
示例#11
0
def test_shelf_save(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["somekey"] = "somevalue"
        shelf.close()

        shelf = None

        # load up the old shelf
        shelf = pc.EncryptedShelf(writer, filename, password)
        assert shelf["somekey"] == "somevalue"
        shelf.close()
示例#12
0
def test_shelf_save(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["somekey"] = "somevalue"
        shelf.close()

        shelf = None

        # load up the old shelf
        shelf = pc.EncryptedShelf(writer, filename, password)
        assert shelf["somekey"] == "somevalue"
        shelf.close()
示例#13
0
def test_write(method):
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write("some test data")
        file.close()
示例#14
0
def test_shelf_set(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        shelf.close()
示例#15
0
def test_write(method):
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.write("some test data")
        file.close()
示例#16
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()
示例#17
0
def test_constructors(method):
    "Test the various file's constructors"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.close()
示例#18
0
def test_shelf_set(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf["key"] = "value"
        assert shelf["key"] == "value"
        shelf.close()
示例#19
0
def test_constructors(method):
    "Test the various file's constructors"
    with file_cleanup(test_file):
        file = method(open(test_file, 'w'), test_pass)
        file.close()
示例#20
0
def test_shelf_create(writer, filename, password):
    with file_cleanup(test_file):
        shelf = pc.EncryptedShelf(writer, filename, password)
        shelf.close()