48 lines
806 B
Python
48 lines
806 B
Python
|
|
from libsaria import path
|
|
from libsaria.map import Map
|
|
key = "key"
|
|
|
|
# __init__
|
|
test = Map()
|
|
print "Testing basic functions (no persistance):"
|
|
# has
|
|
print " Has key <False>?", test.has(key)
|
|
# __getitem__
|
|
print " test[key] <None>?", test[key]
|
|
|
|
# __setitem__
|
|
print " Setting test[key] = True"
|
|
test[key] = True
|
|
|
|
# has
|
|
print " Has key <True>?", test.has(key)
|
|
# __getitem__
|
|
print " test[key] <True>?", test['key']
|
|
|
|
|
|
print
|
|
print "Testing persistance:"
|
|
file = path.join(path.join(path.sariadir(),".saria"),"tests.map.pickle")
|
|
try:
|
|
path.rm(file)
|
|
except:
|
|
pass
|
|
del test
|
|
|
|
test = Map("tests.map")
|
|
test["a"] = 0
|
|
test["b"] = 0
|
|
print " print test"
|
|
print test
|
|
print " del test"
|
|
del test
|
|
print " test = Map(\"tests.map\")"
|
|
test = Map("tests.map")
|
|
print " print test"
|
|
print test
|
|
try:
|
|
path.rm(file)
|
|
except:
|
|
pass
|