1 #!/usr/bin/env python 2 # 3 # Copyright (C) 2017 The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 # 17 18 import unittest 19 from tradefed_py import base_test 20 from tradefed_py import tf_main 21 22 class HelloWorldTest(base_test._TradefedTestClass): 23 """An example showing a possible implementation of python test""" 24 25 def test_hello(self): 26 self.assertEqual('hello'.upper(), 'HELLO') 27 28 def test_world_failed(self): 29 self.assertEqual('world'.upper(), 'WORLD2') 30 31 @unittest.skip('demonstrating skipping') 32 def test_skipped(self): 33 self.fail('should have been skipped') 34 35 @unittest.expectedFailure 36 def test_expectation(self): 37 self.fail('failed') 38 39 @unittest.expectedFailure 40 def test_failedExpectation(self): 41 pass 42 43 def test_device(self): 44 """If a serial was provided this test will check that we can query the 45 device. It will throw if the serial is invalid. 46 """ 47 if self.serial is not None: 48 res = self.android_device.executeShellCommand('id') 49 self.assertTrue('uid' in res) 50 51 if __name__ == '__main__': 52 tf_main.main() 53