mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Use Samba-only subunit module in selftest/tests/.
Change-Id: I48c61f975c1fa49f6e244ad39dd720fe507db45b Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Andrew Bartlett
parent
9a1a34451f
commit
8487f4afc1
@ -16,3 +16,31 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
"""Subunit test protocol."""
|
"""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()
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
$ python -m samba.subunit.run mylib.tests.test_suite
|
$ python -m samba.subunit.run mylib.tests.test_suite
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from samba.subunit import UTC
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -31,25 +33,6 @@ import traceback
|
|||||||
import unittest
|
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
|
# Whether or not to hide layers of the stack trace that are
|
||||||
# unittest/testtools internal code. Defaults to True since the
|
# unittest/testtools internal code. Defaults to True since the
|
||||||
# system-under-test is rarely unittest or testtools.
|
# system-under-test is rarely unittest or testtools.
|
||||||
|
@ -18,10 +18,9 @@
|
|||||||
"""Test command running."""
|
"""Test command running."""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from subunit import iso8601
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import subunit
|
from samba import subunit
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import warnings
|
import warnings
|
||||||
@ -89,7 +88,7 @@ def exported_envvars_str(vars, names):
|
|||||||
def now():
|
def now():
|
||||||
"""Return datetime instance for current time in UTC.
|
"""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):
|
def run_testsuite_command(name, cmd, subunit_ops, env=None, outf=None):
|
||||||
|
@ -21,7 +21,10 @@
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
import subunit
|
from samba.subunit import (
|
||||||
|
PROGRESS_PUSH,
|
||||||
|
PROGRESS_POP,
|
||||||
|
)
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from selftest.run import (
|
from selftest.run import (
|
||||||
@ -133,10 +136,10 @@ class RunTestsuiteCommandTests(TestCase):
|
|||||||
exit_code = run_testsuite_command("thetestsuitename", "echo doing something", subunit_ops, outf=outf)
|
exit_code = run_testsuite_command("thetestsuitename", "echo doing something", subunit_ops, outf=outf)
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
("start-testsuite", "thetestsuitename"),
|
("start-testsuite", "thetestsuitename"),
|
||||||
("progress", None, subunit.PROGRESS_PUSH),
|
("progress", None, PROGRESS_PUSH),
|
||||||
("time", ),
|
("time", ),
|
||||||
("time", ),
|
("time", ),
|
||||||
("progress", None, subunit.PROGRESS_POP),
|
("progress", None, PROGRESS_POP),
|
||||||
("end-testsuite", "thetestsuitename", "success", None),
|
("end-testsuite", "thetestsuitename", "success", None),
|
||||||
], subunit_ops.calls)
|
], subunit_ops.calls)
|
||||||
self.assertEquals(0, exit_code)
|
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)
|
exit_code = run_testsuite_command("thetestsuitename", "exit 3", subunit_ops, outf=outf)
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
("start-testsuite", "thetestsuitename"),
|
("start-testsuite", "thetestsuitename"),
|
||||||
("progress", None, subunit.PROGRESS_PUSH),
|
("progress", None, PROGRESS_PUSH),
|
||||||
("time", ),
|
("time", ),
|
||||||
("time", ),
|
("time", ),
|
||||||
("progress", None, subunit.PROGRESS_POP),
|
("progress", None, PROGRESS_POP),
|
||||||
("end-testsuite", "thetestsuitename", "failure", "Exit code was 3"),
|
("end-testsuite", "thetestsuitename", "failure", "Exit code was 3"),
|
||||||
], subunit_ops.calls)
|
], subunit_ops.calls)
|
||||||
self.assertEquals(3, exit_code)
|
self.assertEquals(3, exit_code)
|
||||||
@ -173,10 +176,10 @@ expanded command: exit 3
|
|||||||
"thisisacommandthatdoesnotexist 2>/dev/null", subunit_ops, outf=outf)
|
"thisisacommandthatdoesnotexist 2>/dev/null", subunit_ops, outf=outf)
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
("start-testsuite", "thetestsuitename"),
|
("start-testsuite", "thetestsuitename"),
|
||||||
("progress", None, subunit.PROGRESS_PUSH),
|
("progress", None, PROGRESS_PUSH),
|
||||||
("time", ),
|
("time", ),
|
||||||
("time", ),
|
("time", ),
|
||||||
("progress", None, subunit.PROGRESS_POP),
|
("progress", None, PROGRESS_POP),
|
||||||
("end-testsuite", "thetestsuitename", "failure", "Exit code was 127"),
|
("end-testsuite", "thetestsuitename", "failure", "Exit code was 127"),
|
||||||
], subunit_ops.calls)
|
], subunit_ops.calls)
|
||||||
self.assertEquals(127, exit_code)
|
self.assertEquals(127, exit_code)
|
||||||
|
Reference in New Issue
Block a user