Browse Source

[1290] move some things to terrain.py

Jelte Jansen 13 years ago
parent
commit
e009438536

+ 2 - 1
src/lib/python/isc/bind10/sockcreator.py

@@ -17,6 +17,7 @@ import socket
 import struct
 import os
 import subprocess
+import copy
 from isc.log_messages.bind10_messages import *
 from libutil_io_python import recv_fd
 
@@ -207,7 +208,7 @@ class Creator(Parser):
         # stdin as well as stdout, so we dup it before passing it there.
         remote2 = socket.fromfd(remote.fileno(), socket.AF_UNIX,
                                 socket.SOCK_STREAM)
-        env = os.environ
+        env = copy.deepcopy(os.environ)
         env['PATH'] = path
         self.__process = subprocess.Popen(['b10-sockcreator'], env=env,
                                           stdin=remote.fileno(),

+ 1 - 26
tests/lettuce/features/steps.py

@@ -1,30 +1,5 @@
 from lettuce import *
-import subprocess
-import os.path
-import shutil
-
-copylist = [
-["configurations/example.org.config.orig", "configurations/example.org.config"]
-]
-
-@before.each_scenario
-def initialize(feature):
-    # just make sure our cleanup won't fail if we never did
-    # run the bind10 instance
-    world.bind10 = None
-    world.bind10_output = []
-    world.last_query_result = None
-
-    # Some tests can modify the settings. If the tests fail half-way, or
-    # don't clean up, this can leave configurations or data in a bad state,
-    # so we copy them from originals before each scenario
-    for item in copylist:
-        shutil.copy(item[0], item[1])
-
-@after.each_scenario
-def cleanup(feature):
-    world.shutdown_server()
-    world.bind10_output = []
+import os
 
 @step('Given I have no database')
 def given_i_have_no_database(step):

+ 41 - 0
tests/lettuce/features/terrain.py

@@ -0,0 +1,41 @@
+#
+# This is the 'terrain' in which the lettuce lives. By convention, this is
+# where global setup and teardown is defined.
+#
+# We declare some attributes of the global 'world' variables here, so the
+# tests can safely assume they are present.
+#
+# We also use it to provide scenario invariants, such as resetting data.
+#
+from lettuce import *
+import subprocess
+import os.path
+import shutil
+
+# This is a list of files that are freshly copied before each scenario
+# The first element is the original, the second is the target that will be
+# used by the tests that need them
+copylist = [
+["configurations/example.org.config.orig", "configurations/example.org.config"]
+]
+
+@before.each_scenario
+def initialize(feature):
+    # just make sure our cleanup won't fail if we never did
+    # run the bind10 instance
+    world.bind10 = None
+    world.bind10_output = []
+    world.last_query_result = None
+
+    # Some tests can modify the settings. If the tests fail half-way, or
+    # don't clean up, this can leave configurations or data in a bad state,
+    # so we copy them from originals before each scenario
+    for item in copylist:
+        shutil.copy(item[0], item[1])
+
+@after.each_scenario
+def cleanup(feature):
+    world.shutdown_server()
+    world.bind10_output = []
+
+