From 59f6e4bd338f503d735a9557ec59b4b145f0931c Mon Sep 17 00:00:00 2001 From: butomo1989 Date: Tue, 30 May 2017 17:25:07 +0200 Subject: [PATCH] Mocked os package in unit tests to clear all warning messages --- src/tests/test_appium.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/tests/test_appium.py b/src/tests/test_appium.py index 9579bc0..f761404 100644 --- a/src/tests/test_appium.py +++ b/src/tests/test_appium.py @@ -14,30 +14,39 @@ class TestAppium(TestCase): os.environ['CONNECT_TO_GRID'] = str(True) self.avd_name = 'test_avd' + @mock.patch('os.popen') @mock.patch('subprocess.check_call') - def test_without_selenium_grid(self, mocked_subprocess): + def test_without_selenium_grid(self, mocked_os, mocked_subprocess): os.environ['CONNECT_TO_GRID'] = str(False) + self.assertFalse(mocked_os.called) self.assertFalse(mocked_subprocess.called) app.appium_run(self.avd_name) + self.assertTrue(mocked_os.called) self.assertTrue(mocked_subprocess.called) + @mock.patch('os.popen') @mock.patch('subprocess.check_call') - def test_with_selenium_grid(self, mocked_subprocess): + def test_with_selenium_grid(self, mocked_os, mocked_subprocess): with mock.patch('src.app.create_node_config') as mocked_config: self.assertFalse(mocked_config.called) + self.assertFalse(mocked_os.called) self.assertFalse(mocked_subprocess.called) app.appium_run(self.avd_name) self.assertTrue(mocked_config.called) + self.assertTrue(mocked_os.called) self.assertTrue(mocked_subprocess.called) + @mock.patch('os.popen') @mock.patch('subprocess.check_call') - def test_invalid_integer(self, mocked_subprocess): + def test_invalid_integer(self, mocked_os, mocked_subprocess): os.environ['APPIUM_PORT'] = 'test' with mock.patch('src.app.create_node_config') as mocked_config: self.assertFalse(mocked_config.called) + self.assertFalse(mocked_os.called) self.assertFalse(mocked_subprocess.called) app.appium_run(self.avd_name) self.assertFalse(mocked_config.called) + self.assertTrue(mocked_os.called) self.assertTrue(mocked_subprocess.called) self.assertRaises(ValueError)