Use Samba-only subunit module in selftest/tests/.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 11 Dec 2014 01:55:16 +0000 (01:55 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 6 Mar 2015 03:41:46 +0000 (04:41 +0100)
Change-Id: I48c61f975c1fa49f6e244ad39dd720fe507db45b
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/subunit/__init__.py
python/samba/subunit/run.py
selftest/run.py
selftest/tests/test_run.py

index 7b609c3ef790d926c44a16193276395d2d4d64c6..f452db6dde56721b38a40689b9b80f76e997aa05 100644 (file)
 #
 
 """Subunit test protocol."""
+
+import datetime
+
+
+PROGRESS_SET = 0
+PROGRESS_CUR = 1
+PROGRESS_PUSH = 2
+PROGRESS_POP = 3
+
+
+# From http://docs.python.org/library/datetime.html
+_ZERO = datetime.timedelta(0)
+
+# A UTC class.
+
+class UTC(datetime.tzinfo):
+    """UTC"""
+
+    def utcoffset(self, dt):
+        return _ZERO
+
+    def tzname(self, dt):
+        return "UTC"
+
+    def dst(self, dt):
+        return _ZERO
+
+utc = UTC()
index 33efd4f6f768fcfb3030f59c10386db7d3ecfbb4..dbe6b241c82cd059ab1e4d7842d4823b90c1de82 100755 (executable)
@@ -24,6 +24,8 @@
   $ python -m samba.subunit.run mylib.tests.test_suite
 """
 
+from samba.subunit import UTC
+
 import datetime
 import os
 import sys
@@ -31,25 +33,6 @@ import traceback
 import unittest
 
 
-# From http://docs.python.org/library/datetime.html
-_ZERO = datetime.timedelta(0)
-
-# A UTC class.
-
-class UTC(datetime.tzinfo):
-    """UTC"""
-
-    def utcoffset(self, dt):
-        return _ZERO
-
-    def tzname(self, dt):
-        return "UTC"
-
-    def dst(self, dt):
-        return _ZERO
-
-utc = UTC()
-
 # Whether or not to hide layers of the stack trace that are
 # unittest/testtools internal code.  Defaults to True since the
 # system-under-test is rarely unittest or testtools.
index 222ac8b1a8becdffe2de3b5f75e8a36825ee5e1f..b7638f0daa8ebc7ef42b383990f1ce19705452a3 100644 (file)
 """Test command running."""
 
 import datetime
-from subunit import iso8601
 import os
 import subprocess
-import subunit
+from samba import subunit
 import sys
 import tempfile
 import warnings
@@ -89,7 +88,7 @@ def exported_envvars_str(vars, names):
 def now():
     """Return datetime instance for current time in UTC.
     """
-    return datetime.datetime.utcnow().replace(tzinfo=iso8601.Utc())
+    return datetime.datetime.utcnow().replace(tzinfo=subunit.UTC())
 
 
 def run_testsuite_command(name, cmd, subunit_ops, env=None, outf=None):
index 35f99e83c756adf42f7c86b068c9cb0630d160e0..829f488cf85f200a80131abc2609d3f649557ba1 100644 (file)
 
 import datetime
 import os
-import subunit
+from samba.subunit import (
+    PROGRESS_PUSH,
+    PROGRESS_POP,
+    )
 import tempfile
 
 from selftest.run import (
@@ -133,10 +136,10 @@ class RunTestsuiteCommandTests(TestCase):
         exit_code = run_testsuite_command("thetestsuitename", "echo doing something", subunit_ops, outf=outf)
         self.assertEquals([
             ("start-testsuite", "thetestsuitename"),
-            ("progress", None, subunit.PROGRESS_PUSH),
+            ("progress", None, PROGRESS_PUSH),
             ("time", ),
             ("time", ),
-            ("progress", None, subunit.PROGRESS_POP),
+            ("progress", None, PROGRESS_POP),
             ("end-testsuite", "thetestsuitename", "success", None),
             ], subunit_ops.calls)
         self.assertEquals(0, exit_code)
@@ -153,10 +156,10 @@ expanded command: echo doing something
         exit_code = run_testsuite_command("thetestsuitename", "exit 3", subunit_ops, outf=outf)
         self.assertEquals([
             ("start-testsuite", "thetestsuitename"),
-            ("progress", None, subunit.PROGRESS_PUSH),
+            ("progress", None, PROGRESS_PUSH),
             ("time", ),
             ("time", ),
-            ("progress", None, subunit.PROGRESS_POP),
+            ("progress", None, PROGRESS_POP),
             ("end-testsuite", "thetestsuitename", "failure", "Exit code was 3"),
             ], subunit_ops.calls)
         self.assertEquals(3, exit_code)
@@ -173,10 +176,10 @@ expanded command: exit 3
             "thisisacommandthatdoesnotexist 2>/dev/null", subunit_ops, outf=outf)
         self.assertEquals([
             ("start-testsuite", "thetestsuitename"),
-            ("progress", None, subunit.PROGRESS_PUSH),
+            ("progress", None, PROGRESS_PUSH),
             ("time", ),
             ("time", ),
-            ("progress", None, subunit.PROGRESS_POP),
+            ("progress", None, PROGRESS_POP),
             ("end-testsuite", "thetestsuitename", "failure", "Exit code was 127"),
             ], subunit_ops.calls)
         self.assertEquals(127, exit_code)