def test_get_temp_filename(self, settings): nb_temp_files_before = len(os.listdir(self.temp_dir)) temp_filename = tmp.get_temp_filename() self.assertIn(self.temp_dir, temp_filename) os.remove(temp_filename) extension = '.png' temp_filename = tmp.get_temp_filename(extension) self.assertIn(extension, temp_filename) os.remove(temp_filename) self.assertEquals(len(os.listdir(self.temp_dir)), nb_temp_files_before)
def test(self): def _path_from_name(name): return os.path.join(os.path.dirname(__file__), 'results/' + name) def _compare(file1, file2, **kwargs): self.assertImageAlmostEqual(_path_from_name(file1), _path_from_name(file2), **kwargs) # Compare identical images _compare('white.png', 'white.png') _compare('red.jpg', 'red.jpg') # Compare close images _compare('gradient.png', 'gradient-broken.png', threshold=7, diff_file=tmp.get_temp_filename('.png')) with self.assertRaises(AssertionError): _compare('red.jpg', 'white.png')