Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from Gagnavarslan/master-status-code-for-xml-r…
Browse files Browse the repository at this point in the history
…eport

status code fix for run with xml report format
  • Loading branch information
arnlaugsson committed Mar 2, 2016
2 parents 6849a80 + 31ede82 commit 0722491
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#


__version__ = '0.2.8dev-2'
__version__ = '0.2.8dev-3'

DEVSERVER_PORT = 8120 # django devserver for internal acceptance tests

Expand Down
9 changes: 8 additions & 1 deletion src/sst/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ def runtests(test_regexps, results_directory, out,
out.write('Test run interrupted\n')
result.stopTestRun()

return len(result.failures) + len(result.errors)
if isinstance(result, testtools.testresult.MultiTestResult):
failures = result._results[0].failures
errors = result._results[0].errors
else:
failures = result.failures
errors = result.errors

return len(failures) + len(errors)


def find_shared_directory(test_dir, shared_directory):
Expand Down
29 changes: 24 additions & 5 deletions src/sst/tests/test_runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ class TestOneFail(unittest.TestCase):
def test_one_fail(self):
self.assertTrue(False)
file: t/test_one_error.py
import unittest
class TestOneError(unittest.TestCase):
def test_one_error(self):
raise Exception()
file: t/test_multi_fail.py
import unittest
class TestMultiFail(unittest.TestCase):
Expand All @@ -154,17 +160,30 @@ def test_fail_2(self):
self.assertTrue(False)
''')

def run_tests(self, args):
def run_tests(self, args, **kwargs):
out = StringIO()
failures = runtests.runtests(args, 'no results directory used', out,
browser_factory=browsers.FirefoxFactory())
return bool(failures)
failures = runtests.runtests(
args, '/tmp', out,
browser_factory=browsers.FirefoxFactory(),
**kwargs)
return failures

def test_pass(self):
self.assertEqual(0, self.run_tests(['test_all_pass$']))

def test_fail(self):
self.assertEqual(1, self.run_tests(['test_one_fail$']))

def test_fail_for_xml(self):
self.assertEqual(1,
self.run_tests(['test_one_fail$'], report_format='xml'))

def test_error(self):
self.assertEqual(1, self.run_tests(['test_one_error$']))

def test_multi_fail(self):
self.assertEqual(1, self.run_tests(['test_fail_.*']))
self.assertEqual(2, self.run_tests(['test_fail_.*']))

def test_multi_fail_for_xml(self):
self.assertEqual(2,
self.run_tests(['test_fail_.*'], report_format='xml'))

0 comments on commit 0722491

Please sign in to comment.