Chromium Code Reviews| Index: media/tools/layout_tests/test_expectations_history_unittest.py |
| diff --git a/media/tools/layout_tests/test_expectations_history_unittest.py b/media/tools/layout_tests/test_expectations_history_unittest.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a5b8a256166608dc8e36d30a0903c37dc5d92107 |
| --- /dev/null |
| +++ b/media/tools/layout_tests/test_expectations_history_unittest.py |
| @@ -0,0 +1,64 @@ |
| +#!/usr/bin/python |
| +# Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| +import time |
| +from datetime import timedelta |
| +from datetime import datetime |
|
dennis_jeffrey
2011/08/25 00:36:46
Re-arrange the above 4 lines to put them in order
imasaki1
2011/08/25 23:57:03
Done.
|
| +from test_expectations_history import TestExpectationsHistory |
| + |
| + |
| +class TestTestExpectaionsHistory(unittest.TestCase): |
| + """A Unittest class for test_expectation_history module.""" |
|
dennis_jeffrey
2011/08/25 00:36:46
'Unit tests for the TestExpectationsHistory class.
imasaki1
2011/08/25 23:57:03
Done.
|
| + |
| + def AssertTestName(self, result_list, testname): |
| + """Assert test name in the result_list |
|
dennis_jeffrey
2011/08/25 00:36:46
add period at end of line
imasaki1
2011/08/25 23:57:03
Done.
|
| + |
| + This method is to chek the test name is in the result. |
|
dennis_jeffrey
2011/08/25 00:36:46
I think this line is unnecessary; the first line o
imasaki1
2011/08/25 23:57:03
Done.
|
| + Args: |
| + result_list: a result list of tuples returned by |
| + |GetDiffBetweenTimesOnly1Diff()|. Each tuple consists of |
| + (old_rev, new_rev, author, date, message, lines) where |
| + |lines| are the entries in the test expectaton |
|
dennis_jeffrey
2011/08/25 00:36:46
'expectaton' --> 'expectation'. Also add a period
imasaki1
2011/08/25 23:57:03
Done.
|
| + testname: a testname string. |
| + |
| + Returns: |
| + True if the result contains the testname. |
|
dennis_jeffrey
2011/08/25 00:36:46
add this: ', and False otherwise.'
imasaki1
2011/08/25 23:57:03
Done.
|
| + """ |
| + for (old_rev, new_rev, author, date, message, lines) in result_list: |
|
dennis_jeffrey
2011/08/25 00:36:46
We only actually need to use variable "lines", so
imasaki1
2011/08/25 23:57:03
Done.
|
| + for line in lines: |
| + if testname in line: |
| + return True |
| + return False |
|
dennis_jeffrey
2011/08/25 00:36:46
I think we can probably reduce this function down
imasaki1
2011/08/25 23:57:03
Done.
|
| + |
| + def testGetDiffBetweenTimes(self): |
| + t = (2011, 8, 20, 0, 0, 0, 0, 0, 0) |
| + ctime = time.mktime(t) |
| + t = (2011, 8, 19, 0, 0, 0, 0, 0, 0) |
| + ptime = time.mktime(t) |
| + testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html' |
| + testname_list = ( |
| + [testname]) |
|
dennis_jeffrey
2011/08/25 00:36:46
Can fit on the previous line
imasaki1
2011/08/25 23:57:03
Done.
|
| + result_list = TestExpectationsHistory.GetDiffBetweenTimes( |
| + ctime, ptime, testname_list) |
| + self.assertTrue(self.AssertTestName(result_list, testname)) |
| + |
| + def testGetDiffBetweenTimesOnly1Diff(self): |
| + ptime = '2011-08-19-23' |
| + ptime = datetime.strptime(ptime, "%Y-%m-%d-%H") |
|
dennis_jeffrey
2011/08/25 00:36:46
Combine the above 2 lines into 1 line
imasaki1
2011/08/25 23:57:03
Done.
|
| + ptime = time.mktime(ptime.timetuple()) |
| + ctime = '2011-08-20-00' |
| + ctime = datetime.strptime(ctime, "%Y-%m-%d-%H") |
|
dennis_jeffrey
2011/08/25 00:36:46
Combine the above 2 lines into 1 line
imasaki1
2011/08/25 23:57:03
Done.
|
| + ctime = time.mktime(ctime.timetuple()) |
| + testname = 'fast/css/getComputedStyle/computed-style-without-renderer.html' |
| + testname_list = ( |
| + [testname]) |
|
dennis_jeffrey
2011/08/25 00:36:46
can fit on the previous line
imasaki1
2011/08/25 23:57:03
Done.
|
| + result_list = TestExpectationsHistory.GetDiffBetweenTimes( |
| + ctime, ptime, testname_list) |
| + self.assertTrue(self.AssertTestName(result_list, testname)) |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |