Added tests for set-root
authorAaron Bentley <aaron.bentley@utoronto.ca>
Thu, 24 Mar 2005 06:03:04 +0000 (06:03 +0000)
committerAaron Bentley <aaron.bentley@utoronto.ca>
Thu, 24 Mar 2005 06:03:04 +0000 (06:03 +0000)
becommands/set_root.py
libbe/tests.py [new file with mode: 0644]

index ff7662a9e29ddf09e0ecd38374a79369abcbb9d6..87e4bdaf7ca1b3c554b58076ee74235742c673de 100644 (file)
@@ -2,6 +2,27 @@
 from libbe import bugdir, cmdutil, rcs
 
 def execute(args):
+    """
+    >>> from libbe import tests
+    >>> dir = tests.Dir()
+    >>> try:
+    ...     bugdir.tree_root(dir.name)
+    ... except bugdir.NoBugDir, e:
+    ...     True
+    True
+    >>> execute([dir.name])
+    No revision control detected.
+    Directory initialized.
+    >>> bd = bugdir.tree_root(dir.name)
+    >>> bd.root = dir.name
+    >>> dir = tests.arch_dir()
+    >>> execute([dir.name+"/{arch}"])
+    Using Arch for revision control.
+    Directory initialized.
+    >>> bd = bugdir.tree_root(dir.name+"/{arch}")
+    >>> bd.root = dir.name
+    >>> tests.clean_up()
+    """
     if len(args) != 1:
         raise cmdutil.UserError("Please supply a directory path")
     dir_rcs = rcs.detect(args[0])
diff --git a/libbe/tests.py b/libbe/tests.py
new file mode 100644 (file)
index 0000000..ecd6ed5
--- /dev/null
@@ -0,0 +1,24 @@
+import tempfile
+import shutil
+import os
+import os.path
+cleanable = []
+def clean_up():
+    global cleanable
+    tmp = cleanable
+    tmp.reverse()
+    for obj in tmp:
+        obj.clean_up()
+    cleanable = []
+
+class Dir:
+    def __init__(self):
+        self.name = tempfile.mkdtemp(prefix="testdir")
+        cleanable.append(self)
+    def clean_up(self):
+        shutil.rmtree(self.name)
+
+def arch_dir():
+    dir = Dir()
+    os.mkdir(os.path.join(dir.name, "{arch}"))
+    return dir