def test_equals(self): self.assertEqual(FailureCrash(), FailureCrash()) self.assertNotEqual(FailureCrash(), FailureTimeout()) crash_set = set([FailureCrash(), FailureCrash()]) self.assertEqual(len(crash_set), 1) # The hash happens to be the name of the class, but sets still work: crash_set = set([FailureCrash(), 'FailureCrash']) self.assertEqual(len(crash_set), 2)
def test_repeated_test_artifacts(self): host = MockSystemHost() port = Port(host, 'baseport') artifacts = Artifacts('/dir', host.filesystem, repeat_tests=True) def init_test_failure(test_failure): test_failure.port = port test_failure.filesystem = host.filesystem test_failure.test_name = 'foo.html' test_failure.result_directory = '/dir' pass_with_stderr = PassWithStderr( DriverOutput(None, None, None, None, error=b'pass with stderr')) init_test_failure(pass_with_stderr) crash = FailureCrash( DriverOutput(None, None, None, None, crash=True, error=b'crash stderr')) init_test_failure(crash) timeout = FailureTimeout( DriverOutput(None, None, None, None, error=b'timeout with stderr')) init_test_failure(timeout) pass_with_stderr.create_artifacts(artifacts) self.assertEqual('pass with stderr', host.filesystem.read_text_file('/dir/foo-stderr.txt')) crash.create_artifacts(artifacts) self.assertEqual('crash stderr', host.filesystem.read_text_file('/dir/foo-stderr.txt')) timeout.create_artifacts(artifacts) self.assertEqual('timeout with stderr', host.filesystem.read_text_file('/dir/foo-stderr.txt')) pass_with_stderr.create_artifacts(artifacts) self.assertEqual('timeout with stderr', host.filesystem.read_text_file('/dir/foo-stderr.txt'))