|
13 | 13 | # See the License for the specific language governing permissions and |
14 | 14 | # limitations under the License. |
15 | 15 |
|
16 | | -import unittest |
17 | 16 | from time import sleep |
18 | 17 |
|
| 18 | +import pytest |
| 19 | + |
19 | 20 | from appium.webdriver.applicationstate import ApplicationState |
20 | 21 |
|
21 | 22 | from .helper.test_helper import APIDEMO_PKG_NAME, BaseTestCase |
22 | 23 |
|
23 | 24 |
|
24 | | -class ApplicationsTests(BaseTestCase): |
| 25 | +class TestApplications(BaseTestCase): |
25 | 26 |
|
26 | 27 | def test_background_app(self) -> None: |
27 | 28 | self.driver.background_app(1) |
28 | 29 | sleep(3) |
29 | 30 | self.driver.launch_app() |
30 | 31 |
|
31 | 32 | def test_is_app_installed(self) -> None: |
32 | | - self.assertFalse(self.driver.is_app_installed('sdfsdf')) |
33 | | - self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME)) |
| 33 | + assert not self.driver.is_app_installed('sdfsdf') |
| 34 | + assert self.driver.is_app_installed(APIDEMO_PKG_NAME) |
34 | 35 |
|
| 36 | + @pytest.mark.skip('This causes the server to crash. no idea why') |
35 | 37 | def test_install_app(self) -> None: |
36 | | - self.skipTest('This causes the server to crash. no idea why') |
37 | | - self.assertFalse(self.driver.is_app_installed('io.selendroid.testapp')) |
| 38 | + assert not self.driver.is_app_installed('io.selendroid.testapp') |
38 | 39 | self.driver.install_app('/Users/isaac/code/python-client/test/apps/selendroid-test-app.apk') |
39 | | - self.assertTrue(self.driver.is_app_installed('io.selendroid.testapp')) |
| 40 | + assert self.driver.is_app_installed('io.selendroid.testapp') |
40 | 41 |
|
41 | 42 | def test_remove_app(self) -> None: |
42 | | - self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME)) |
| 43 | + assert self.driver.is_app_installed(APIDEMO_PKG_NAME) |
43 | 44 | self.driver.remove_app(APIDEMO_PKG_NAME) |
44 | | - self.assertFalse(self.driver.is_app_installed(APIDEMO_PKG_NAME)) |
| 45 | + assert not self.driver.is_app_installed(APIDEMO_PKG_NAME) |
45 | 46 |
|
46 | 47 | def test_close_and_launch_app(self) -> None: |
47 | 48 | self.driver.close_app() |
48 | 49 | self.driver.launch_app() |
49 | 50 | activity = self.driver.current_activity |
50 | | - self.assertEqual('.ApiDemos', activity) |
| 51 | + assert '.ApiDemos' == activity |
51 | 52 |
|
52 | 53 | def test_app_management(self) -> None: |
53 | 54 | app_id = self.driver.current_package |
54 | | - self.assertEqual(self.driver.query_app_state(app_id), |
55 | | - ApplicationState.RUNNING_IN_FOREGROUND) |
| 55 | + assert self.driver.query_app_state(app_id) == ApplicationState.RUNNING_IN_FOREGROUND |
56 | 56 | self.driver.background_app(-1) |
57 | | - self.assertTrue(self.driver.query_app_state(app_id) < |
58 | | - ApplicationState.RUNNING_IN_FOREGROUND) |
| 57 | + assert self.driver.query_app_state(app_id) < ApplicationState.RUNNING_IN_FOREGROUND |
59 | 58 | self.driver.activate_app(app_id) |
60 | | - self.assertEqual(self.driver.query_app_state(app_id), |
61 | | - ApplicationState.RUNNING_IN_FOREGROUND) |
| 59 | + assert self.driver.query_app_state(app_id) == ApplicationState.RUNNING_IN_FOREGROUND |
62 | 60 |
|
63 | 61 | def test_app_strings(self) -> None: |
64 | 62 | strings = self.driver.app_strings() |
65 | | - self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data']) |
| 63 | + assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data'] |
66 | 64 |
|
67 | 65 | def test_app_strings_with_language(self) -> None: |
68 | 66 | strings = self.driver.app_strings('en') |
69 | | - self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data']) |
| 67 | + assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data'] |
70 | 68 |
|
71 | 69 | def test_app_strings_with_language_and_file(self) -> None: |
72 | 70 | strings = self.driver.app_strings('en', 'some_file') |
73 | | - self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data']) |
| 71 | + assert u'You can\'t wipe my data, you are a monkey!' == strings[u'monkey_wipe_data'] |
74 | 72 |
|
75 | 73 | def test_reset(self) -> None: |
76 | 74 | self.driver.reset() |
77 | | - self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME)) |
78 | | - |
79 | | - |
80 | | -if __name__ == '__main__': |
81 | | - suite = unittest.TestLoader().loadTestsFromTestCase(ApplicationsTests) |
82 | | - unittest.TextTestRunner(verbosity=2).run(suite) |
| 75 | + assert self.driver.is_app_installed(APIDEMO_PKG_NAME) |
0 commit comments