summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJonathan Lange <jml@mumak.net>2006-12-02 15:42:35 +1100
committerJonathan Lange <jml@mumak.net>2006-12-02 15:42:35 +1100
commitbb7e4124b6d945551c5e4444a8f5b44dac211d74 (patch)
tree963c520069fa2536db9c9ecf2b7a5040440add7e /python
parent9b53011391cd95e68dc9a4e9a8633adef5a020d8 (diff)
downloadsubunit-git-bb7e4124b6d945551c5e4444a8f5b44dac211d74.tar.gz
Use absolute paths so the tests run from trial
Diffstat (limited to 'python')
-rw-r--r--python/subunit/tests/TestUtil.py10
-rw-r--r--python/subunit/tests/test_test_protocol.py13
2 files changed, 16 insertions, 7 deletions
diff --git a/python/subunit/tests/TestUtil.py b/python/subunit/tests/TestUtil.py
index 7c6b5fb..d883f70 100644
--- a/python/subunit/tests/TestUtil.py
+++ b/python/subunit/tests/TestUtil.py
@@ -16,6 +16,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+import os
import sys
import logging
import unittest
@@ -39,6 +40,11 @@ def makeCollectingLogger():
return logger, handler
+def mockFile(filename):
+ return os.path.join(os.path.dirname(os.path.abspath(__file__)),
+ filename)
+
+
def visitTests(suite, visitor):
"""A foreign method for visiting the tests in a test suite."""
for test in suite._tests:
@@ -50,7 +56,7 @@ def visitTests(suite, visitor):
if isinstance(test, unittest.TestCase):
visitor.visitCase(test)
elif isinstance(test, unittest.TestSuite):
- visitor.visitSuite(test)
+ #visitor.visitSuite(test)
visitTests(test, visitor)
else:
print "unvisitable non-unittest.TestCase element %r (%r)" % (test, test.__class__)
@@ -64,7 +70,7 @@ class TestSuite(unittest.TestSuite):
def visit(self, visitor):
"""visit the composite. Visiting is depth-first.
current callbacks are visitSuite and visitCase."""
- visitor.visitSuite(self)
+ #visitor.visitSuite(self)
visitTests(self, visitor)
diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py
index eb77e68..ae5af0c 100644
--- a/python/subunit/tests/test_test_protocol.py
+++ b/python/subunit/tests/test_test_protocol.py
@@ -21,6 +21,7 @@ import unittest
from StringIO import StringIO
import subunit
import sys
+from subunit.tests.TestUtil import mockFile
try:
class MockTestProtocolServerClient(object):
@@ -561,14 +562,15 @@ class TestExecTestCase(unittest.TestCase):
class SampleExecTestCase(subunit.ExecTestCase):
def test_sample_method(self):
- """./python/subunit/tests/sample-script.py"""
- # the sample script runs three tests, one each
- # that fails, errors and succeeds
+ pass
+ test_sample_method.__doc__ = mockFile("sample-script.py")
+ # the sample script runs three tests, one each
+ # that fails, errors and succeeds
def test_construct(self):
test = self.SampleExecTestCase("test_sample_method")
- self.assertEqual(test.script, "./python/subunit/tests/sample-script.py")
+ self.assertEqual(test.script, mockFile("sample-script.py"))
def test_run(self):
runner = MockTestProtocolServerClient()
@@ -597,7 +599,8 @@ class TestExecTestCase(unittest.TestCase):
class DoExecTestCase(subunit.ExecTestCase):
def test_working_script(self):
- """./python/subunit/tests/sample-two-script.py"""
+ pass
+ test_working_script.__doc__ = mockFile("sample-two-script.py")
class TestIsolatedTestCase(unittest.TestCase):