Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(356)

Side by Side Diff: gm/rebaseline_server/compare_to_expectations_test.py

Issue 397103003: combine base_unittest.py modules from gm and tools (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: pylint Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 """ 3 """
4 Copyright 2013 Google Inc. 4 Copyright 2013 Google Inc.
5 5
6 Use of this source code is governed by a BSD-style license that can be 6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file. 7 found in the LICENSE file.
8 8
9 Test compare_to_expectations.py 9 Test compare_to_expectations.py
10 10
11 TODO(epoger): Create a command to update the expected results (in 11 TODO(epoger): Create a command to update the expected results (in
12 self._output_dir_expected) when appropriate. For now, you should: 12 self._output_dir_expected) when appropriate. For now, you should:
13 1. examine the results in self._output_dir_actual and make sure they are ok 13 1. examine the results in self.output_dir_actual and make sure they are ok
14 2. rm -rf self._output_dir_expected 14 2. rm -rf self._output_dir_expected
15 3. mv self._output_dir_actual self._output_dir_expected 15 3. mv self.output_dir_actual self._output_dir_expected
16 Although, if you're using an SVN checkout, this will blow away .svn directories 16 Although, if you're using an SVN checkout, this will blow away .svn directories
17 within self._output_dir_expected, which wouldn't be good... 17 within self._output_dir_expected, which wouldn't be good...
18 18
19 """ 19 """
20 20
21 import os 21 import os
22 22
23 # Imports from within Skia 23 # Imports from within Skia
24 import base_unittest 24 import base_unittest
25 import compare_to_expectations 25 import compare_to_expectations
26 import imagediffdb 26 import imagediffdb
27 import results 27 import results
28 import gm_json # must import results first, so that gm_json will be in sys.path 28 import gm_json # must import results first, so that gm_json will be in sys.path
29 29
30 30
31 class CompareToExpectationsTest(base_unittest.TestCase): 31 class CompareToExpectationsTest(base_unittest.TestCase):
32 32
33 def test_gm(self): 33 def test_gm(self):
34 """Process results of a GM run with the ExpectationComparisons object.""" 34 """Process results of a GM run with the ExpectationComparisons object."""
35 image_diff_db = imagediffdb.ImageDiffDB(storage_root=self._temp_dir) 35 image_diff_db = imagediffdb.ImageDiffDB(storage_root=self.temp_dir)
36 results_obj = compare_to_expectations.ExpectationComparisons( 36 results_obj = compare_to_expectations.ExpectationComparisons(
37 image_diff_db=image_diff_db, 37 image_diff_db=image_diff_db,
38 actuals_root=os.path.join(self._input_dir, 'gm-actuals'), 38 actuals_root=os.path.join(self.input_dir, 'gm-actuals'),
39 expected_root=os.path.join(self._input_dir, 'gm-expectations'), 39 expected_root=os.path.join(self.input_dir, 'gm-expectations'),
40 diff_base_url='/static/generated-images') 40 diff_base_url='/static/generated-images')
41 results_obj.get_timestamp = mock_get_timestamp 41 results_obj.get_timestamp = mock_get_timestamp
42 gm_json.WriteToFile( 42 gm_json.WriteToFile(
43 results_obj.get_packaged_results_of_type( 43 results_obj.get_packaged_results_of_type(
44 results.KEY__HEADER__RESULTS_ALL), 44 results.KEY__HEADER__RESULTS_ALL),
45 os.path.join(self._output_dir_actual, 'gm.json')) 45 os.path.join(self.output_dir_actual, 'gm.json'))
46 46
47 47
48 def mock_get_timestamp(): 48 def mock_get_timestamp():
49 """Mock version of BaseComparisons.get_timestamp() for testing.""" 49 """Mock version of BaseComparisons.get_timestamp() for testing."""
50 return 12345678 50 return 12345678
51 51
52 52
53 def main(): 53 def main():
54 base_unittest.main(CompareToExpectationsTest) 54 base_unittest.main(CompareToExpectationsTest)
55 55
56 56
57 if __name__ == '__main__': 57 if __name__ == '__main__':
58 main() 58 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698