def test__hash__(self): r1 = testoutput.TextTestOutput( 'mac', FakeFile('test-expected.txt', 'contents')) r2 = testoutput.TextTestOutput( 'mac', FakeFile('test-expected.txt', 'contents')) r3 = testoutput.TextTestOutput(None, FakeFile('test-expected.txt', None)) x = set([r1, r2]) self.assertEquals(1, len(set([r1, r2]))) self.assertEquals(2, len(set([r1, r2, r3])))
def test__eq__(self): r1 = testoutput.TextTestOutput( 'mac', FakeFile('test-expected.txt', 'contents')) r2 = testoutput.TextTestOutput( 'mac', FakeFile('test-expected.txt', 'contents')) r3 = testoutput.TextTestOutput( 'win', FakeFile('test-expected.txt', 'contents')) self.assertEquals(r1, r2) self.assertEquals(r1, r2.retarget('mac')) self.assertNotEquals(r1, r2.retarget('win'))
def _check_platform(self, filename, expected_platform): # FIXME: should consider using MockFileSystem here so as to not # have to worry about platform-specific path separators. if sys.platform == 'win32': filename = filename.replace('/', os.path.sep) r = testoutput.TextTestOutput(None, FakeFile(filename)) self.assertEquals(expected_platform, r.platform())
def outputs_for(self, name, **kwargs): target_type = kwargs.get('target_type', None) exact_match = kwargs.get('exact_match', False) if re.search(r'\.x?html', name): name = name[:name.rindex('.')] (checksum_files, text_files, image_files) = self._extract_output_files(name, exact_match) outputs = [ self._make_output_from_image(image_file, checksum_files) for image_file in image_files ] outputs += [ testoutput.TextTestOutput(self._platform, text_file) for text_file in text_files ] if exact_match: outputs = filter(lambda output: output.name() == name, outputs) outputs = filter(lambda r: target_type in [None, r.type()], outputs) return outputs
def test_outputs_from_an_actual_file_are_marked_as_such(self): r = testoutput.TextTestOutput(None, FakeFile('test-actual.txt')) self.assertTrue(r.is_actual())
def test_is_new_baseline_for(self): expected = testoutput.TextTestOutput('mac', FakeFile('test-expected.txt')) actual = testoutput.TextTestOutput('mac', FakeFile('test-actual.txt')) self.assertTrue(actual.is_new_baseline_for(expected)) self.assertFalse(expected.is_new_baseline_for(actual))
def test_outputs_from_an_expected_file_are_not_actual(self): r = testoutput.TextTestOutput(None, FakeFile('test-expected.txt')) self.assertFalse(r.is_actual())