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

Unified Diff: build/android/pylib/instrumentation/instrumentation_test_instance_test.py

Issue 1851143002: Find annotated tests by exposing API in instrumentation_test_instance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: build/android/pylib/instrumentation/instrumentation_test_instance_test.py
diff --git a/build/android/pylib/instrumentation/instrumentation_test_instance_test.py b/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
index 7a0b91c4c955b1dbc023f220c882f1688dc01cfd..85d4e41feb2461b83cae2f0fa18effe93dce258c 100755
--- a/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
+++ b/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
@@ -16,6 +16,8 @@ from pylib.instrumentation import instrumentation_test_instance
with host_paths.SysPath(host_paths.PYMOCK_PATH):
import mock # pylint: disable=import-error
+_INSTRUMENTATION_TEST_INSTANCE_PATH = (
+ 'pylib.instrumentation.instrumentation_test_instance.%s')
class InstrumentationTestInstanceTest(unittest.TestCase):
@@ -25,8 +27,7 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
@staticmethod
def createTestInstance():
- c = ('pylib.instrumentation.instrumentation_test_instance.'
- 'InstrumentationTestInstance')
+ c = _INSTRUMENTATION_TEST_INSTANCE_PATH % 'InstrumentationTestInstance'
with mock.patch('%s._initializeApkAttributes' % c), (
mock.patch('%s._initializeDataDependencyAttributes' % c)), (
mock.patch('%s._initializeTestFilterAttributes' % c)), (
@@ -66,8 +67,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
-
expected_tests = [
{
'annotations': {
@@ -95,7 +94,10 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGetTests_simpleGtestFilter(self):
@@ -117,9 +119,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._test_filter = 'org.chromium.test.SampleTest.testMethod1'
-
expected_tests = [
{
'annotations': {
@@ -131,7 +130,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._test_filter = 'org.chromium.test.SampleTest.testMethod1'
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGetTests_wildcardGtestFilter(self):
@@ -163,9 +166,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._test_filter = 'org.chromium.test.SampleTest2.*'
-
expected_tests = [
{
'annotations': {
@@ -177,7 +177,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._test_filter = 'org.chromium.test.SampleTest2.*'
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
@unittest.skip('crbug.com/623047')
@@ -264,9 +268,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._annotations = {'SmallTest': None}
-
expected_tests = [
{
'annotations': {
@@ -286,7 +287,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._annotations = {'SmallTest': None}
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGetTests_excludedAnnotationFilter(self):
@@ -318,9 +323,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._excluded_annotations = {'SmallTest': None}
-
expected_tests = [
{
'annotations': {
@@ -332,7 +334,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._excluded_annotations = {'SmallTest': None}
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGetTests_annotationSimpleValueFilter(self):
@@ -373,9 +379,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._annotations = {'TestValue': '1'}
-
expected_tests = [
{
'annotations': {
@@ -388,7 +391,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._annotations = {'TestValue': '1'}
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGetTests_annotationDictValueFilter(self):
@@ -420,9 +427,6 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
}
]
- o._GetTestsFromPickle = mock.MagicMock(return_value=raw_tests)
- o._annotations = {'Feature': 'Bar'}
-
expected_tests = [
{
'annotations': {
@@ -434,7 +438,11 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
},
]
- actual_tests = o.GetTests()
+ o._annotations = {'Feature': 'Bar'}
+ with mock.patch(_INSTRUMENTATION_TEST_INSTANCE_PATH % '_GetTestsFromPickle',
+ return_value=raw_tests):
+ actual_tests = o.GetTests()
+
self.assertEquals(actual_tests, expected_tests)
def testGenerateTestResults_noStatus(self):
« no previous file with comments | « build/android/pylib/instrumentation/instrumentation_test_instance.py ('k') | tools/android/find_annotated_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698