diff options
author | John Reck <jreck@google.com> | 2010-11-04 12:00:17 -0700 |
---|---|---|
committer | John Reck <jreck@google.com> | 2010-11-09 11:35:04 -0800 |
commit | e14391e94c850b8bd03680c23b38978db68687a8 (patch) | |
tree | 3fed87e6620fecaf3edc7259ae58a11662bedcb2 /WebKitTools/Scripts/webkitpy/layout_tests/layout_package | |
parent | 1bd705833a68f07850cf7e204b26f8d328d16951 (diff) | |
download | external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.zip external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.gz external_webkit-e14391e94c850b8bd03680c23b38978db68687a8.tar.bz2 |
Merge Webkit at r70949: Initial merge by git.
Change-Id: I77b8645c083b5d0da8dba73ed01d4014aab9848e
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/layout_tests/layout_package')
9 files changed, 191 insertions, 76 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py index e0fd1b6..3e3ba0b 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/dump_render_tree_thread.py @@ -51,6 +51,7 @@ import time import traceback import test_failures +import test_results _log = logging.getLogger("webkitpy.layout_tests.layout_package." "dump_render_tree_thread") @@ -133,8 +134,8 @@ def _process_output(port, options, test_info, test_types, test_args, time.time() - start_diff_time) total_time_for_all_diffs = time.time() - start_diff_time - return TestResult(test_info.filename, failures, test_run_time, - total_time_for_all_diffs, time_for_diffs) + return test_results.TestResult(test_info.filename, failures, test_run_time, + total_time_for_all_diffs, time_for_diffs) def _pad_timeout(timeout): @@ -152,16 +153,11 @@ def _milliseconds_to_seconds(msecs): return float(msecs) / 1000.0 -class TestResult(object): - - def __init__(self, filename, failures, test_run_time, - total_time_for_all_diffs, time_for_diffs): - self.failures = failures - self.filename = filename - self.test_run_time = test_run_time - self.time_for_diffs = time_for_diffs - self.total_time_for_all_diffs = total_time_for_all_diffs - self.type = test_failures.determine_result_type(failures) +def _image_hash(test_info, test_args, options): + """Returns the image hash of the test if it's needed, otherwise None.""" + if (test_args.new_baseline or test_args.reset_results or not options.pixel_tests): + return None + return test_info.image_hash() class SingleTestThread(threading.Thread): @@ -196,10 +192,11 @@ class SingleTestThread(threading.Thread): self._driver = self._port.create_driver(self._test_args.png_path, self._options) self._driver.start() + image_hash = _image_hash(test_info, self._test_args, self._options) start = time.time() crash, timeout, actual_checksum, output, error = \ self._driver.run_test(test_info.uri.strip(), test_info.timeout, - test_info.image_hash()) + image_hash) end = time.time() self._test_result = _process_output(self._port, self._options, test_info, self._test_types, self._test_args, @@ -256,8 +253,8 @@ class TestShellThread(WatchableThread): options: command line options argument from optparse filename_list_queue: A thread safe Queue class that contains lists of tuples of (filename, uri) pairs. - result_queue: A thread safe Queue class that will contain tuples of - (test, failure lists) for the test results. + result_queue: A thread safe Queue class that will contain + serialized TestResult objects. test_types: A list of TestType objects to run the test output against. test_args: A TestArguments object to pass to each TestType. @@ -441,7 +438,7 @@ class TestShellThread(WatchableThread): else: _log.debug("%s %s passed" % (self.getName(), self._port.relative_test_filename(filename))) - self._result_queue.put(result) + self._result_queue.put(result.dumps()) if batch_size > 0 and batch_count > batch_size: # Bounce the shell and reset count. @@ -497,9 +494,8 @@ class TestShellThread(WatchableThread): failures = [] _log.error('Cannot get results of test: %s' % test_info.filename) - result = TestResult(test_info.filename, failures=[], - test_run_time=0, total_time_for_all_diffs=0, - time_for_diffs=0) + result = test_results.TestResult(test_info.filename, failures=[], + test_run_time=0, total_time_for_all_diffs=0, time_for_diffs=0) return result @@ -509,20 +505,14 @@ class TestShellThread(WatchableThread): Args: test_info: Object containing the test filename, uri and timeout - Returns: - A list of TestFailure objects describing the error. - + Returns: a TestResult object. """ self._ensure_dump_render_tree_is_running() # The pixel_hash is used to avoid doing an image dump if the # checksums match, so it should be set to a blank value if we # are generating a new baseline. (Otherwise, an image from a # previous run will be copied into the baseline.) - image_hash = test_info.image_hash() - if (image_hash and - (self._test_args.new_baseline or self._test_args.reset_results or - not self._options.pixel_tests)): - image_hash = "" + image_hash = _image_hash(test_info, self._test_args, self._options) start = time.time() thread_timeout = _milliseconds_to_seconds( diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py index c6c3066..1cf88ef 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py @@ -42,7 +42,6 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase # Additional JSON fields. WONTFIX = "wontfixCounts" - DEFERRED = "deferredCounts" # Note that we omit test_expectations.FAIL from this list because # it should never show up (it's a legacy input expectation, never @@ -167,9 +166,6 @@ class JSONLayoutResultsGenerator(json_results_generator.JSONResultsGeneratorBase len(self._expectations.get_tests_with_timeline( test_expectations.NOW)), self.ALL_FIXABLE_COUNT) self._insert_item_into_raw_list(results_for_builder, - self._get_failure_summary_entry(test_expectations.DEFER), - self.DEFERRED) - self._insert_item_into_raw_list(results_for_builder, self._get_failure_summary_entry(test_expectations.WONTFIX), self.WONTFIX) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py index 0344aa7..9a0f4ee 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/printing_unittest.py @@ -40,7 +40,7 @@ from webkitpy.common import array_stream from webkitpy.common.system import logtesting from webkitpy.layout_tests import port from webkitpy.layout_tests.layout_package import printing -from webkitpy.layout_tests.layout_package import dump_render_tree_thread +from webkitpy.layout_tests.layout_package import test_results from webkitpy.layout_tests.layout_package import test_expectations from webkitpy.layout_tests.layout_package import test_failures from webkitpy.layout_tests import run_webkit_tests @@ -141,9 +141,9 @@ class Testprinter(unittest.TestCase): elif result_type == test_expectations.CRASH: failures = [test_failures.FailureCrash()] path = os.path.join(self._port.layout_tests_dir(), test) - return dump_render_tree_thread.TestResult(path, failures, run_time, - total_time_for_all_diffs=0, - time_for_diffs=0) + return test_results.TestResult(path, failures, run_time, + total_time_for_all_diffs=0, + time_for_diffs=0) def get_result_summary(self, tests, expectations_str): test_paths = [os.path.join(self._port.layout_tests_dir(), test) for diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py index 508a6ad..67873a8 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py @@ -43,7 +43,7 @@ _log = logging.getLogger("webkitpy.layout_tests.layout_package." # Test expectation and modifier constants. (PASS, FAIL, TEXT, IMAGE, IMAGE_PLUS_TEXT, TIMEOUT, CRASH, SKIP, WONTFIX, - DEFER, SLOW, REBASELINE, MISSING, FLAKY, NOW, NONE) = range(16) + SLOW, REBASELINE, MISSING, FLAKY, NOW, NONE) = range(15) # Test expectation file update action constants (NO_CHANGE, REMOVE_TEST, REMOVE_PLATFORM, ADD_PLATFORMS_EXCEPT_THIS) = range(4) @@ -228,12 +228,11 @@ class TestExpectationsFile: DEBUG : LayoutTests/fast/js/no-good.js = TIMEOUT PASS DEBUG SKIP : LayoutTests/fast/js/no-good.js = TIMEOUT PASS LINUX DEBUG SKIP : LayoutTests/fast/js/no-good.js = TIMEOUT PASS - DEFER LINUX WIN : LayoutTests/fast/js/no-good.js = TIMEOUT PASS + LINUX WIN : LayoutTests/fast/js/no-good.js = TIMEOUT PASS SKIP: Doesn't run the test. SLOW: The test takes a long time to run, but does not timeout indefinitely. WONTFIX: For tests that we never intend to pass on a given platform. - DEFER: Test does not count in our statistics for the current release. DEBUG: Expectations apply only to the debug build. RELEASE: Expectations apply only to release build. LINUX/WIN/WIN-XP/WIN-VISTA/WIN-7/MAC: Expectations apply only to these @@ -241,7 +240,6 @@ class TestExpectationsFile: Notes: -A test cannot be both SLOW and TIMEOUT - -A test cannot be both DEFER and WONTFIX -A test should only be one of IMAGE, TEXT, IMAGE+TEXT, or FAIL. FAIL is a migratory state that currently means either IMAGE, TEXT, or IMAGE+TEXT. Once we have finished migrating the expectations, we will @@ -249,7 +247,7 @@ class TestExpectationsFile: identifier. -A test can be included twice, but not via the same path. -If a test is included twice, then the more precise path wins. - -CRASH tests cannot be DEFER or WONTFIX + -CRASH tests cannot be WONTFIX """ EXPECTATIONS = {'pass': PASS, @@ -282,14 +280,12 @@ class TestExpectationsFile: MODIFIERS = {'skip': SKIP, 'wontfix': WONTFIX, - 'defer': DEFER, 'slow': SLOW, 'rebaseline': REBASELINE, 'none': NONE} TIMELINES = {'wontfix': WONTFIX, - 'now': NOW, - 'defer': DEFER} + 'now': NOW} RESULT_TYPES = {'skip': SKIP, 'pass': PASS, @@ -621,10 +617,6 @@ class TestExpectationsFile: if not self._is_debug_mode and 'release' not in options: return False - if 'wontfix' in options and 'defer' in options: - self._add_error(lineno, 'Test cannot be both DEFER and WONTFIX.', - test_and_expectations) - if self._is_lint_mode and 'rebaseline' in options: self._add_error(lineno, 'REBASELINE should only be used for running rebaseline.py. ' @@ -773,8 +765,6 @@ class TestExpectationsFile: if 'wontfix' in modifiers: self._timeline_to_tests[WONTFIX].add(test) - elif 'defer' in modifiers: - self._timeline_to_tests[DEFER].add(test) else: self._timeline_to_tests[NOW].add(test) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py index 2e1b6ec..55eaf99 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations_unittest.py @@ -134,17 +134,12 @@ class TestExpectationsTest(Base): self.get_test('failures/expected/text.html')), set([TEXT, CRASH])) - def test_defer(self): - self.parse_exp('BUGX DEFER : failures/expected/text.html = TEXT') - self.assertEqual(self._exp.get_options( - self.get_test('failures/expected/text.html')), ['bugx', 'defer']) - def test_precedence(self): # This tests handling precedence of specific lines over directories # and tests expectations covering entire directories. exp_str = """ BUGX : failures/expected/text.html = TEXT -BUGX DEFER : failures/expected = IMAGE +BUGX WONTFIX : failures/expected = IMAGE """ self.parse_exp(exp_str) self.assert_exp('failures/expected/text.html', TEXT) @@ -227,11 +222,6 @@ BUGX DEFER : failures/expected = IMAGE self.assertRaises(SyntaxError, self.parse_exp, 'BUG_TEST SLOW : failures/expected/timeout.html = TIMEOUT') - def test_semantic_wontfix_defer(self): - # A test cannot be WONTFIX and DEFER. - self.assertRaises(SyntaxError, self.parse_exp, - 'BUG_TEST WONTFIX DEFER : failures/expected/text.html = TEXT') - def test_semantic_rebaseline(self): # Can't lint a file w/ 'REBASELINE' in it. self.assertRaises(SyntaxError, self.parse_exp, diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py index 340d075..6d55761 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py @@ -32,6 +32,8 @@ import os import test_expectations +import cPickle + def determine_result_type(failure_list): """Takes a set of test_failures and returns which result type best fits @@ -71,10 +73,25 @@ class TestFailure(object): """Abstract base class that defines the failure interface.""" @staticmethod + def loads(s): + """Creates a TestFailure object from the specified string.""" + return cPickle.loads(s) + + @staticmethod def message(): """Returns a string describing the failure in more detail.""" raise NotImplementedError + def __eq__(self, other): + return self.__class__.__name__ == other.__class__.__name__ + + def __ne__(self, other): + return self.__class__.__name__ != other.__class__.__name__ + + def dumps(self): + """Returns the string/JSON representation of a TestFailure.""" + return cPickle.dumps(self) + def result_html_output(self, filename): """Returns an HTML string to be included on the results.html page.""" raise NotImplementedError @@ -112,7 +129,7 @@ class FailureWithType(TestFailure): TestFailure.__init__(self) # Filename suffixes used by ResultHtmlOutput. - OUT_FILENAMES = [] + OUT_FILENAMES = () def output_links(self, filename, out_names): """Returns a string holding all applicable output file links. @@ -128,6 +145,10 @@ class FailureWithType(TestFailure): # FIXME: Seems like a bad idea to separate the display name data # from the path data by hard-coding the display name here # and passing in the path information via out_names. + # + # FIXME: Also, we don't know for sure that these files exist, + # and we shouldn't be creating links to files that don't exist + # (for example, if we don't actually have wdiff output). links = [''] uris = [self.relative_output_filename(filename, fn) for fn in out_names] @@ -170,7 +191,7 @@ class FailureCrash(TestFailure): return "Test shell crashed" def result_html_output(self, filename): - # TODO(tc): create a link to the minidump file + # FIXME: create a link to the minidump file stack = self.relative_output_filename(filename, "-stack.txt") return "<strong>%s</strong> <a href=%s>stack</a>" % (self.message(), stack) @@ -181,7 +202,7 @@ class FailureCrash(TestFailure): class FailureMissingResult(FailureWithType): """Expected result was missing.""" - OUT_FILENAMES = ["-actual.txt"] + OUT_FILENAMES = ("-actual.txt",) @staticmethod def message(): @@ -196,14 +217,8 @@ class FailureTextMismatch(FailureWithType): """Text diff output failed.""" # Filename suffixes used by ResultHtmlOutput. # FIXME: Why don't we use the constants from TestTypeBase here? - OUT_FILENAMES = ["-actual.txt", "-expected.txt", "-diff.txt"] - OUT_FILENAMES_WDIFF = ["-actual.txt", "-expected.txt", "-diff.txt", - "-wdiff.html", "-pretty-diff.html"] - - def __init__(self, has_wdiff): - FailureWithType.__init__(self) - if has_wdiff: - self.OUT_FILENAMES = self.OUT_FILENAMES_WDIFF + OUT_FILENAMES = ("-actual.txt", "-expected.txt", "-diff.txt", + "-wdiff.html", "-pretty-diff.html") @staticmethod def message(): @@ -214,7 +229,6 @@ class FailureMissingImageHash(FailureWithType): """Actual result hash was missing.""" # Chrome doesn't know to display a .checksum file as text, so don't bother # putting in a link to the actual result. - OUT_FILENAMES = [] @staticmethod def message(): @@ -226,7 +240,7 @@ class FailureMissingImageHash(FailureWithType): class FailureMissingImage(FailureWithType): """Actual result image was missing.""" - OUT_FILENAMES = ["-actual.png"] + OUT_FILENAMES = ("-actual.png",) @staticmethod def message(): @@ -239,7 +253,7 @@ class FailureMissingImage(FailureWithType): class FailureImageHashMismatch(FailureWithType): """Image hashes didn't match.""" - OUT_FILENAMES = ["-actual.png", "-expected.png", "-diff.png"] + OUT_FILENAMES = ("-actual.png", "-expected.png", "-diff.png") @staticmethod def message(): @@ -252,7 +266,6 @@ class FailureImageHashIncorrect(FailureWithType): """Actual result hash is incorrect.""" # Chrome doesn't know to display a .checksum file as text, so don't bother # putting in a link to the actual result. - OUT_FILENAMES = [] @staticmethod def message(): @@ -260,3 +273,10 @@ class FailureImageHashIncorrect(FailureWithType): def result_html_output(self, filename): return "<strong>%s</strong>" % self.message() + +# Convenient collection of all failure classes for anything that might +# need to enumerate over them all. +ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult, + FailureTextMismatch, FailureMissingImageHash, + FailureMissingImage, FailureImageHashMismatch, + FailureImageHashIncorrect) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py index 92fe276..3e3528d 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures_unittest.py @@ -28,13 +28,26 @@ """"Tests code paths not covered by the regular unit tests.""" -from webkitpy.layout_tests.layout_package.test_failures import * import unittest +from webkitpy.layout_tests.layout_package.test_failures import * + + class Test(unittest.TestCase): def assertResultHtml(self, failure_obj): self.assertNotEqual(failure_obj.result_html_output('foo'), None) + def assert_loads(self, cls): + failure_obj = cls() + s = failure_obj.dumps() + new_failure_obj = TestFailure.loads(s) + self.assertTrue(isinstance(new_failure_obj, cls)) + + self.assertEqual(failure_obj, new_failure_obj) + + # Also test that != is implemented. + self.assertFalse(failure_obj != new_failure_obj) + def test_crash(self): self.assertResultHtml(FailureCrash()) @@ -63,6 +76,9 @@ class Test(unittest.TestCase): self.assertRaises(NotImplementedError, failure_obj.result_html_output, "foo.txt") + def test_loads(self): + for c in ALL_FAILURE_CLASSES: + self.assert_loads(c) if __name__ == '__main__': unittest.main() diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results.py new file mode 100644 index 0000000..2417fb7 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results.py @@ -0,0 +1,61 @@ +# Copyright (C) 2010 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import cPickle + +import test_failures + + +class TestResult(object): + """Data object containing the results of a single test.""" + + @staticmethod + def loads(str): + return cPickle.loads(str) + + def __init__(self, filename, failures, test_run_time, + total_time_for_all_diffs, time_for_diffs): + self.failures = failures + self.filename = filename + self.test_run_time = test_run_time + self.time_for_diffs = time_for_diffs + self.total_time_for_all_diffs = total_time_for_all_diffs + self.type = test_failures.determine_result_type(failures) + + def __eq__(self, other): + return (self.filename == other.filename and + self.failures == other.failures and + self.test_run_time == other.test_run_time and + self.time_for_diffs == other.time_for_diffs and + self.total_time_for_all_diffs == other.total_time_for_all_diffs) + + def __ne__(self, other): + return not (self == other) + + def dumps(self): + return cPickle.dumps(self) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results_unittest.py new file mode 100644 index 0000000..5921666 --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_results_unittest.py @@ -0,0 +1,52 @@ +# Copyright (C) 2010 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import unittest + +from test_results import TestResult + + +class Test(unittest.TestCase): + def test_loads(self): + result = TestResult(filename='foo', + failures=[], + test_run_time=1.1, + total_time_for_all_diffs=0.5, + time_for_diffs=0.5) + s = result.dumps() + new_result = TestResult.loads(s) + self.assertTrue(isinstance(new_result, TestResult)) + + self.assertEqual(new_result, result) + + # Also check that != is implemented. + self.assertFalse(new_result != result) + + +if __name__ == '__main__': + unittest.main() |