Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

second refactoring of resume logic test #2

  • Loading branch information...
commit b0d0a2053f475eff8b9d398e1db4e1d86797db2c 1 parent f7b9006
@lirazsiri lirazsiri authored
Showing with 15 additions and 10 deletions.
  1. +15 −10 tests/resume.py
View
25 tests/resume.py
@@ -12,14 +12,20 @@
class Error(Exception):
pass
-def session_load():
- return simplejson.loads(file(SESSION_FILE).read())
+class Session:
+ SESSION_FILE = '/tmp/session'
-def session_save(conf):
- file(SESSION_FILE, "w").write(simplejson.dumps(conf))
+ @classmethod
+ def load(cls):
+ return simplejson.loads(file(cls.SESSION_FILE).read())
-def session_remove():
- os.remove(SESSION_FILE)
+ @classmethod
+ def save(cls, conf):
+ file(cls.SESSION_FILE, "w").write(simplejson.dumps(conf))
+
+ @classmethod
+ def remove(cls):
+ os.remove(cls.SESSION_FILE)
def main():
try:
@@ -36,8 +42,7 @@ def main():
opt_resume = True
try:
- prev_conf = session_load()
-
+ prev_conf = Session.load()
except:
prev_conf = None
@@ -61,9 +66,9 @@ def main():
print "conf: " + `conf`
print "opt_resume = " + `opt_resume`
- session_save(conf)
+ Session.save(conf)
time.sleep(3)
- session_remove()
+ Session.remove()
if __name__ == "__main__":
main()
Please sign in to comment.
Something went wrong with that request. Please try again.