From d80c36842de93b5198fe934e34145fe749d399a0 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 23 May 2013 18:07:41 +0100 Subject: [PATCH] Bold link? --- README.rst | 3 ++- tests/bootstrap/unittesting.py | 4 ++++ tests/runtests.py | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ddb5e8d..e2024d2 100644 --- a/README.rst +++ b/README.rst @@ -9,7 +9,8 @@ script runs through a series of checks to determine operating system type and ve install the `Salt`_ binaries using the appropriate methods. -**In case you found a bug, please read** `I found a bug`_ **first before submitting a new issue.** +**In case you found a bug, please read** `**I found a bug**`_ **first before submitting a new +issue.** One Line Bootstrap diff --git a/tests/bootstrap/unittesting.py b/tests/bootstrap/unittesting.py index 1d0f9f4..98a515c 100644 --- a/tests/bootstrap/unittesting.py +++ b/tests/bootstrap/unittesting.py @@ -33,6 +33,8 @@ if sys.version_info < (2, 7): expectedFailure, TestSuite, skipIf, + TestResult, + Testrogram ) except ImportError: raise SystemExit('You need to install unittest2 to run the salt tests') @@ -44,6 +46,8 @@ else: expectedFailure, TestSuite, skipIf, + TestResult, + TestProgram ) diff --git a/tests/runtests.py b/tests/runtests.py index f360c39..5c01f1c 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -19,6 +19,7 @@ import tempfile from bootstrap.unittesting import TestLoader, TextTestRunner from bootstrap.ext.os_data import GRAINS +from bootstrap.ext.HTMLTestRunner import HTMLTestRunner try: from bootstrap.ext import console width, height = console.getTerminalSize() @@ -39,6 +40,11 @@ XML_OUTPUT_DIR = os.environ.get( tempfile.gettempdir(), 'xml-test-reports' ) ) +HTML_OUTPUT_DIR = os.environ.get( + 'HTML_OUTPUT_DIR', os.path.join( + tempfile.gettempdir(), 'html-test-results' + ) +) def print_header(header, sep='~', top=True, bottom=True, inline=False, @@ -70,7 +76,7 @@ def run_suite(opts, path, display_name, suffix='[!_]*.py'): ''' loader = TestLoader() if opts.name: - tests = tests = loader.loadTestsFromName(display_name) + tests = loader.loadTestsFromName(display_name) else: tests = loader.discover(path, suffix, TEST_DIR) @@ -84,6 +90,23 @@ def run_suite(opts, path, display_name, suffix='[!_]*.py'): output=XML_OUTPUT_DIR, verbosity=opts.verbosity ).run(tests) + elif opts.html_out: + if not os.path.isdir(HTML_OUTPUT_DIR): + os.makedirs(HTML_OUTPUT_DIR) + + for test in tests._tests: + for t in test: + print 2, t._tests + if not t._tests: + continue + print str(t._tests[0].__class__.__name__) + print dir(test) + exit(1) + runner = HTMLTestRunner( + stream=open(HTML_OUTPUT_DIR, 'w'), + verbosity=opts.verbosity + ).run(tests) + TEST_RESULTS.append((header, runner)) else: runner = TextTestRunner( verbosity=opts.verbosity @@ -153,6 +176,14 @@ def main(): XML_OUTPUT_DIR ) ) + output_options_group.add_option( + '--html-out', + default=False, + action='store_true', + help='HTML test runner output(Output directory: {0})'.format( + HTML_OUTPUT_DIR + ) + ) output_options_group.add_option( '--no-clean', default=False,