updated file to PEP 8, as editor was complaining, and tabs are generally bad

This commit is contained in:
Kelsey Hawley 2014-01-02 16:29:15 -08:00
parent 39fb1c75ba
commit 4b0ab0ff72

View File

@ -35,14 +35,16 @@ val1 = 'very first value'
val2 = 'second value' val2 = 'second value'
dump_anydbm = "dump-anydbm" dump_anydbm = "dump-anydbm"
@pytest.fixture(scope = "function")
@pytest.fixture(scope="function")
def make_gdbm_test_db(request): def make_gdbm_test_db(request):
db_name ="test_gdbm" db_name = "test_gdbm"
print("creating", db_name) print("creating", db_name)
test_db = gdbm.open(db_name, "n") test_db = gdbm.open(db_name, "n")
test_db[key1] = val1 test_db[key1] = val1
test_db[key2] = val2 test_db[key2] = val2
test_db.close() test_db.close()
def delete_test_dumbdbm(): def delete_test_dumbdbm():
print("deleting", db_name) print("deleting", db_name)
os.remove(db_name) os.remove(db_name)
@ -50,7 +52,8 @@ def make_gdbm_test_db(request):
request.addfinalizer(delete_test_dumbdbm) request.addfinalizer(delete_test_dumbdbm)
return db_name return db_name
@pytest.fixture(scope = "function")
@pytest.fixture(scope="function")
def make_ndbm_test_db(request): def make_ndbm_test_db(request):
db_name = "test_ndbm" db_name = "test_ndbm"
print("creating", db_name) print("creating", db_name)
@ -58,34 +61,38 @@ def make_ndbm_test_db(request):
test_db[key1] = val1 test_db[key1] = val1
test_db[key2] = val2 test_db[key2] = val2
test_db.close() test_db.close()
def delete_test_ndbm(): def delete_test_ndbm():
print("deleting", db_name) print("deleting", db_name)
os.remove(db_name+".db") os.remove(db_name + ".db")
request.addfinalizer(delete_test_ndbm) request.addfinalizer(delete_test_ndbm)
return db_name return db_name
@pytest.fixture(scope = "function")
@pytest.fixture(scope="function")
def make_dumbdbm_test_db(request): def make_dumbdbm_test_db(request):
db_name ="test_dumbdbm" db_name = "test_dumbdbm"
print("creating", db_name) print("creating", db_name)
test_db = dumb.open(db_name, "n") test_db = dumb.open(db_name, "n")
test_db[key1] = val1 test_db[key1] = val1
test_db[key2] = val2 test_db[key2] = val2
test_db.close() test_db.close()
def delete_test_dumbdbm(): def delete_test_dumbdbm():
print("deleting", db_name) print("deleting", db_name)
os.remove(db_name+".dir") os.remove(db_name + ".dir")
os.remove(db_name+".bak") os.remove(db_name + ".bak")
os.remove(db_name+".dat") os.remove(db_name + ".dat")
request.addfinalizer(delete_test_dumbdbm) request.addfinalizer(delete_test_dumbdbm)
return db_name return db_name
def test_dumpanydbm_identify_gdbm(make_gdbm_test_db): def test_dumpanydbm_identify_gdbm(make_gdbm_test_db):
print("running test_dumpanydbm_identify_gdbm") print("running test_dumpanydbm_identify_gdbm")
output = subprocess.check_output([dump_anydbm, make_gdbm_test_db]) output = subprocess.check_output([dump_anydbm, make_gdbm_test_db])
output = output.decode(encoding = 'UTF-8').strip().split("\n") output = output.decode(encoding='UTF-8').strip().split("\n")
assert len(output) == 3 # 2 keys plus whichdb line assert len(output) == 3 # 2 keys plus whichdb line
# split on space, then grab 4th word, which is db type # split on space, then grab 4th word, which is db type
@ -102,10 +109,11 @@ def test_dumpanydbm_identify_gdbm(make_gdbm_test_db):
assert db_dump_second_pair[0] == key2 assert db_dump_second_pair[0] == key2
assert db_dump_second_pair[1] == val2 assert db_dump_second_pair[1] == val2
def test_dumpanydbm_identify_ndbm(make_ndbm_test_db): def test_dumpanydbm_identify_ndbm(make_ndbm_test_db):
print("running test_dumpanydbm_identify_ndbm") print("running test_dumpanydbm_identify_ndbm")
output = subprocess.check_output([dump_anydbm, make_ndbm_test_db]) output = subprocess.check_output([dump_anydbm, make_ndbm_test_db])
output = output.decode(encoding = 'UTF-8').strip().split("\n") output = output.decode(encoding='UTF-8').strip().split("\n")
assert len(output) == 3 # 2 keys plus whichdb line assert len(output) == 3 # 2 keys plus whichdb line
@ -123,10 +131,11 @@ def test_dumpanydbm_identify_ndbm(make_ndbm_test_db):
assert db_dump_second_pair[0] == key2 assert db_dump_second_pair[0] == key2
assert db_dump_second_pair[1] == val2 assert db_dump_second_pair[1] == val2
def test_dumpanydbm_identify_dumbdbm(make_dumbdbm_test_db): def test_dumpanydbm_identify_dumbdbm(make_dumbdbm_test_db):
print("running test_dumpanydbm_identify_dumbdbm") print("running test_dumpanydbm_identify_dumbdbm")
output = subprocess.check_output([dump_anydbm, make_dumbdbm_test_db]) output = subprocess.check_output([dump_anydbm, make_dumbdbm_test_db])
output = output.decode(encoding = 'UTF-8').strip().split("\n") output = output.decode(encoding='UTF-8').strip().split("\n")
assert len(output) == 3 # 2 keys plus whichdb line assert len(output) == 3 # 2 keys plus whichdb line
print(output) print(output)