steps.py 1006 B

123456789101112131415161718192021222324252627282930313233343536
  1. from lettuce import *
  2. import subprocess
  3. import os.path
  4. import shutil
  5. copylist = [
  6. ["configurations/example.org.config.orig", "configurations/example.org.config"]
  7. ]
  8. @before.each_scenario
  9. def initialize(feature):
  10. # just make sure our cleanup won't fail if we never did
  11. # run the bind10 instance
  12. world.bind10 = None
  13. world.bind10_output = []
  14. # Some tests can modify the settings. If the tests fail half-way, or
  15. # don't clean up, this can leave configurations or data in a bad state,
  16. # so we copy them from originals before each scenario
  17. for item in copylist:
  18. shutil.copy(item[0], item[1])
  19. @after.each_scenario
  20. def cleanup(feature):
  21. world.shutdown_server()
  22. world.bind10_output = []
  23. @step(u'Given I have no database')
  24. def given_i_have_no_database(step):
  25. if os.path.exists("test.db"):
  26. os.remove("test.db")
  27. @step(u'I should see a database file')
  28. def i_should_see_a_database_file(step):
  29. assert os.path.exists("test.db")
  30. os.remove("test.db")