From 0b9d5a896901c8c4805e13900fec7ad1c452eaf0 Mon Sep 17 00:00:00 2001 From: dtopuzov Date: Fri, 6 Dec 2019 16:05:04 +0200 Subject: [PATCH 01/10] chore: fix flaky tests --- data/sync/master_detail_vue.py | 20 +++++++++---------- products/nativescript/app.py | 2 +- run_ns.py | 2 +- tests/cli/build/android_app_bundle_tests.py | 12 +++++------ .../preview/templates/hello_word_js_tests.py | 6 +++++- .../preview/templates/hello_word_ng_tests.py | 9 +++++++-- tests/perf/app_size/test_app_size.py | 18 ++++++++--------- tests/vue/test_vue_preview.py | 3 +++ 8 files changed, 42 insertions(+), 30 deletions(-) diff --git a/data/sync/master_detail_vue.py b/data/sync/master_detail_vue.py index 127e22c8..1683a807 100644 --- a/data/sync/master_detail_vue.py +++ b/data/sync/master_detail_vue.py @@ -6,8 +6,8 @@ from selenium.webdriver.common.by import By from core.enums.app_type import AppType -from core.enums.platform_type import Platform from core.enums.os_type import OSType +from core.enums.platform_type import Platform from core.settings import Settings from core.utils.appium.appium_driver import AppiumDriver from core.utils.wait import Wait @@ -19,11 +19,11 @@ from products.nativescript.tns_paths import TnsPaths -def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): +def sync_master_detail_vue(app_name, platform, device): # Execute tns command - result = Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False, bundle=bundle, hmr=hmr) - strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.FULL, bundle=bundle, - hmr=hmr, app_type=AppType.VUE, transfer_all=True) + result = Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False) + strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.FULL, app_type=AppType.VUE, + transfer_all=True) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=360) # start appium driver (need it on iOS only) @@ -38,7 +38,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): device.get_screen(path=initial_state) # Verify that application is not restarted on file changes when hmr=true - if hmr and Settings.HOST_OS != OSType.WINDOWS: + if Settings.HOST_OS != OSType.WINDOWS: not_existing_string_list = ['Restarting application'] else: not_existing_string_list = None @@ -46,7 +46,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): # Edit template in .vue file Sync.replace(app_name=app_name, change_set=Changes.MasterDetailVUE.VUE_TEMPLATE) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, - bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarList.vue') + app_type=AppType.VUE, file_name='CarList.vue') TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) device.wait_for_text(text=Changes.MasterDetailVUE.VUE_TEMPLATE.new_text) @@ -54,7 +54,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): # Edit styling in .vue file Sync.replace(app_name=app_name, change_set=Changes.MasterDetailVUE.VUE_STYLE) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, - bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarList.vue') + app_type=AppType.VUE, file_name='CarList.vue') TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.LIGHT_BLUE) > 200) @@ -63,7 +63,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): # Revert styling in .vue file Sync.revert(app_name=app_name, change_set=Changes.MasterDetailVUE.VUE_STYLE) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, - bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarList.vue') + app_type=AppType.VUE, file_name='CarList.vue') TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) style_applied = Wait.until(lambda: device.get_pixels_by_color(Colors.LIGHT_BLUE) < 200) @@ -79,7 +79,7 @@ def sync_master_detail_vue(app_name, platform, device, bundle=True, hmr=True): device.wait_for_text(text="Price") Sync.replace(app_name=app_name, change_set=Changes.MasterDetailVUE.VUE_DETAIL_PAGE_TEMPLATE) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.INCREMENTAL, - bundle=bundle, hmr=hmr, app_type=AppType.VUE, file_name='CarDetails.vue') + app_type=AppType.VUE, file_name='CarDetails.vue') TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, not_existing_string_list=not_existing_string_list) device.wait_for_text(text=Changes.MasterDetailVUE.VUE_DETAIL_PAGE_TEMPLATE.new_text) diff --git a/products/nativescript/app.py b/products/nativescript/app.py index 8402db0d..a1de7d34 100644 --- a/products/nativescript/app.py +++ b/products/nativescript/app.py @@ -84,7 +84,7 @@ def update(app_name, modules=True, angular=True, typescript=False, web_pack=True if vue and App.is_dependency(app_name=app_name, dependency='nativescript-vue'): Npm.uninstall(package='nativescript-vue', option='--save', folder=app_path) - Npm.install(package='nativescript-vue@next', option='--save --save-exact', folder=app_path) + Npm.install(package='nativescript-vue', option='--save --save-exact', folder=app_path) # on win when `npm i` is executed with path to .tgz it saves in package.json unix style path # which cannot be resolved on win if Settings.HOST_OS == OSType.WINDOWS: diff --git a/run_ns.py b/run_ns.py index 08a10cd0..7767e85b 100644 --- a/run_ns.py +++ b/run_ns.py @@ -8,7 +8,7 @@ if __name__ == '__main__': run_common.prepare(clone_templates=True, install_ng_cli=False) Log.info("Running tests...") - arguments = ['nosetests', '-v', '-s', '--nologcapture', '--with-doctest', '--with-xunit'] + arguments = ['nosetests', '-v', '-s', '--nologcapture', '--with-doctest', '--with-xunit', '--with-flaky'] for i in sys.argv: arguments.append(str(i)) nose.run(argv=arguments) diff --git a/tests/cli/build/android_app_bundle_tests.py b/tests/cli/build/android_app_bundle_tests.py index 49a03353..15fcb386 100644 --- a/tests/cli/build/android_app_bundle_tests.py +++ b/tests/cli/build/android_app_bundle_tests.py @@ -3,9 +3,9 @@ from core.base_test.tns_run_android_test import TnsRunAndroidTest from core.settings.Settings import TEST_SUT_HOME, TEST_RUN_HOME, AppName, Android from core.utils.device.adb import Adb +from core.utils.docker import Docker from core.utils.file_utils import Folder, File from core.utils.run import run -from core.utils.docker import Docker from data.templates import Template from products.nativescript.tns import Tns from products.nativescript.tns_logs import TnsLogs @@ -60,9 +60,9 @@ def bundletool_build(bundletool_path, path_to_aab, path_to_apks): @staticmethod def bundletool_deploy(bundletool_path, path_to_apks, device_id): - deploy_command = ('java -jar {0} install-apks --apks="{1}" --device-id={2}').format(bundletool_path, - path_to_apks, - device_id) + deploy_command = 'java -jar {0} install-apks --apks="{1}" --device-id={2}'.format(bundletool_path, + path_to_apks, + device_id) result = run(deploy_command) assert "Error" not in result.output, "deploy of app failed" assert "The APKs have been extracted in the directory:" in result.output, "deploy of app failed" @@ -81,11 +81,11 @@ def test_100_run_android_app_bundle_compile_snapshot(self): uglify=True, verify=False, compile_snapshot=True) strings = ['Successfully generated snapshots', 'The build result is located at: {0}'.format(path_to_aab)] - TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=180) + TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=240) # Verify app can be deployed on emulator via nativescript # Verify app looks correct inside emulator - self.emu.wait_for_text(text='TAP', timeout=240) + self.emu.wait_for_text(text='TAP', timeout=60) # Verify that the correct .so file is included in the package File.unzip(path_to_apks, os.path.join(self.app_name, 'apks')) diff --git a/tests/cli/preview/templates/hello_word_js_tests.py b/tests/cli/preview/templates/hello_word_js_tests.py index 4fa22ee2..e583db39 100644 --- a/tests/cli/preview/templates/hello_word_js_tests.py +++ b/tests/cli/preview/templates/hello_word_js_tests.py @@ -1,6 +1,8 @@ import os import unittest +from flaky import flaky + from core.base_test.tns_run_test import TnsRunTest from core.base_test.tns_test import TnsTest from core.enums.app_type import AppType @@ -15,8 +17,8 @@ from data.templates import Template from products.nativescript.preview_helpers import Preview from products.nativescript.tns import Tns -from products.nativescript.tns_logs import TnsLogs from products.nativescript.tns_assert import TnsAssert +from products.nativescript.tns_logs import TnsLogs class TnsPreviewJSTests(TnsRunTest): @@ -73,11 +75,13 @@ def test_100_preview_ios(self): preview_sync_hello_world_js_ts(app_type=AppType.JS, app_name=self.app_name, device=self.sim, click_open_alert=True) + @flaky(max_runs=3) def test_205_preview_android_no_hmr(self): """Preview project on emulator with --no-hmr. Make valid changes in JS, CSS and XML""" preview_sync_hello_world_js_ts(app_type=AppType.JS, app_name=self.app_name, device=self.emu, hmr=False) + @flaky(max_runs=3) @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_205_preview_ios_no_hmr(self): """Preview project on simulator with --no-hmr. Make valid changes in JS, CSS and XML""" diff --git a/tests/cli/preview/templates/hello_word_ng_tests.py b/tests/cli/preview/templates/hello_word_ng_tests.py index 4f1f99f8..a22cfde4 100644 --- a/tests/cli/preview/templates/hello_word_ng_tests.py +++ b/tests/cli/preview/templates/hello_word_ng_tests.py @@ -1,15 +1,18 @@ import os import unittest -from core.base_test.tns_test import TnsTest + +from flaky import flaky + from core.base_test.tns_run_test import TnsRunTest +from core.base_test.tns_test import TnsTest from core.enums.os_type import OSType from core.enums.platform_type import Platform from core.settings import Settings from core.utils.file_utils import File, Folder from data.sync.hello_world_ng import preview_sync_hello_world_ng from data.templates import Template -from products.nativescript.tns import Tns from products.nativescript.preview_helpers import Preview +from products.nativescript.tns import Tns class TnsPreviewNGTests(TnsRunTest): @@ -65,11 +68,13 @@ def test_100_preview_ios(self): preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.IOS, device=self.sim, instrumented=True) + @flaky(max_runs=3) def test_205_preview_android_no_hmr(self): """Preview project on emulator with --hmr. Make valid changes in TS, CSS and HTML""" preview_sync_hello_world_ng(app_name=self.app_name, platform=Platform.ANDROID, device=self.emu, hmr=False) + @flaky(max_runs=3) @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_205_preview_ios_no_hmr(self): """Preview project on simulator with --hmr. Make valid changes in TS, CSS and HTML""" diff --git a/tests/perf/app_size/test_app_size.py b/tests/perf/app_size/test_app_size.py index 2d13faed..626c3863 100644 --- a/tests/perf/app_size/test_app_size.py +++ b/tests/perf/app_size/test_app_size.py @@ -52,11 +52,11 @@ def tearDownClass(cls): def test_001_js_app_app_resources(self): folder = os.path.join(TnsPaths.get_app_path(app_name=self.js_app), 'app') - assert PerfUtils.is_value_in_range(actual=Folder.get_size(folder), expected=1267420, tolerance=0.1) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(folder), expected=1268131, tolerance=0.1) def test_002_js_app_node_modules(self): folder = os.path.join(TnsPaths.get_app_path(app_name=self.js_app), 'node_modules') - assert PerfUtils.is_value_in_range(actual=Folder.get_size(folder), expected=54883579, tolerance=0.1) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(folder), expected=58628036, tolerance=0.1) def test_003_js_app_apk(self): # Extract APK @@ -71,9 +71,9 @@ def test_003_js_app_apk(self): run(cmd='du -hs *', cwd=lib, wait=True, log_level=logging.INFO) # Verify content of APK - assert PerfUtils.is_value_in_range(actual=Folder.get_size(lib), expected=51266016, tolerance=0.05) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(lib), expected=51992248, tolerance=0.05) assert PerfUtils.is_value_in_range(actual=Folder.get_size(res), expected=796627, tolerance=0.05) - assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=839462, tolerance=0.05) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=1210914, tolerance=0.05) assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=10621384, tolerance=0.05) # Verify final apk size @@ -82,15 +82,15 @@ def test_003_js_app_apk(self): @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_102_js_app_ipa(self): ipa = TnsPaths.get_ipa_path(app_name=self.js_app, release=True, for_device=True) - assert PerfUtils.is_value_in_range(actual=File.get_size(ipa), expected=14030096, tolerance=0.02) + assert PerfUtils.is_value_in_range(actual=File.get_size(ipa), expected=14465180, tolerance=0.02) def test_100_ng_app_app_resources(self): app_folder = os.path.join(TnsPaths.get_app_path(app_name=self.ng_app), 'App_Resources') - assert PerfUtils.is_value_in_range(actual=Folder.get_size(app_folder), expected=1262116, tolerance=0.1) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(app_folder), expected=1262699, tolerance=0.1) def test_101_ng_app_node_modules(self): app_folder = os.path.join(TnsPaths.get_app_path(app_name=self.ng_app), 'node_modules') - assert PerfUtils.is_value_in_range(actual=Folder.get_size(app_folder), expected=206440791, tolerance=0.1) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(app_folder), expected=210482662, tolerance=0.1) def test_102_ng_app_apk(self): # Extract APK @@ -102,7 +102,7 @@ def test_102_ng_app_apk(self): assets_snapshots = os.path.join(extracted_apk, 'assets', 'snapshots') # No asserts for lib and res, since it is same as JS project - assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=1636691, tolerance=0.05) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=1991318, tolerance=0.05) assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=21822104, tolerance=0.05) # Verify final apk size @@ -111,4 +111,4 @@ def test_102_ng_app_apk(self): @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_102_ng_app_ipa(self): ipa = TnsPaths.get_ipa_path(app_name=self.ng_app, release=True, for_device=True) - assert PerfUtils.is_value_in_range(actual=File.get_size(ipa), expected=14238596, tolerance=0.02) + assert PerfUtils.is_value_in_range(actual=File.get_size(ipa), expected=14672899, tolerance=0.02) diff --git a/tests/vue/test_vue_preview.py b/tests/vue/test_vue_preview.py index 458e81ba..16c98317 100644 --- a/tests/vue/test_vue_preview.py +++ b/tests/vue/test_vue_preview.py @@ -1,6 +1,8 @@ import os import unittest +from flaky import flaky + from core.base_test.tns_run_test import TnsRunTest from core.enums.os_type import OSType from core.enums.platform_type import Platform @@ -12,6 +14,7 @@ from products.nativescript.tns import Tns +@flaky(max_runs=3) class VueJSPreviewTests(TnsRunTest): app_name = Settings.AppName.DEFAULT source_project_dir = os.path.join(Settings.TEST_RUN_HOME, app_name) From 7d96bc11dd1c4ea4a166aac1c4d87a9facebbf6e Mon Sep 17 00:00:00 2001 From: dtopuzov Date: Fri, 6 Dec 2019 16:29:41 +0200 Subject: [PATCH 02/10] chore: update more perf values --- tests/perf/app_size/test_app_size.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/perf/app_size/test_app_size.py b/tests/perf/app_size/test_app_size.py index 626c3863..2188f8d1 100644 --- a/tests/perf/app_size/test_app_size.py +++ b/tests/perf/app_size/test_app_size.py @@ -74,7 +74,7 @@ def test_003_js_app_apk(self): assert PerfUtils.is_value_in_range(actual=Folder.get_size(lib), expected=51992248, tolerance=0.05) assert PerfUtils.is_value_in_range(actual=Folder.get_size(res), expected=796627, tolerance=0.05) assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=1210914, tolerance=0.05) - assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=10621384, tolerance=0.05) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=16023484, tolerance=0.05) # Verify final apk size assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=24304589, tolerance=0.03) @@ -103,7 +103,7 @@ def test_102_ng_app_apk(self): # No asserts for lib and res, since it is same as JS project assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_app), expected=1991318, tolerance=0.05) - assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=21822104, tolerance=0.05) + assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=27041144, tolerance=0.05) # Verify final apk size assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=26988067, tolerance=0.03) From d3f083e029ff8f9591606e4315d44e440d4114d1 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 16:32:56 +0200 Subject: [PATCH 03/10] chore: multiple fixes --- core/base_test/tns_test.py | 12 +++++++++++- data/sync/master_detail_vue.py | 6 +++++- tests/cli/build/android_app_bundle_tests.py | 2 +- tests/perf/app_size/test_app_size.py | 6 +++--- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/core/base_test/tns_test.py b/core/base_test/tns_test.py index e0b7e010..be0f6a1a 100644 --- a/core/base_test/tns_test.py +++ b/core/base_test/tns_test.py @@ -3,6 +3,8 @@ import os import unittest +import pyautogui + from core.base_test.test_context import TestContext from core.enums.os_type import OSType from core.log.log import Log @@ -108,9 +110,17 @@ def kill_emulators(): @staticmethod def get_screenshots(): + # get host snapshot + base_path = os.path.join(Settings.TEST_OUT_IMAGES, TestContext.CLASS_NAME, TestContext.TEST_NAME) + try: + png_path = os.path.join(base_path, 'host.png') + pyautogui.screenshot().save(png_path) + except (IOError, ValueError): + Log.warning('Failed to take screenshot of host os.') + + # get device screenshots for device in TestContext.STARTED_DEVICES: try: - base_path = os.path.join(Settings.TEST_OUT_IMAGES, TestContext.CLASS_NAME, TestContext.TEST_NAME) png_path = os.path.join(base_path, device.name + '.png') File.delete(png_path) device.get_screen(png_path) diff --git a/data/sync/master_detail_vue.py b/data/sync/master_detail_vue.py index 1683a807..715066df 100644 --- a/data/sync/master_detail_vue.py +++ b/data/sync/master_detail_vue.py @@ -21,7 +21,11 @@ def sync_master_detail_vue(app_name, platform, device): # Execute tns command - result = Tns.run(app_name=app_name, platform=platform, emulator=True, wait=False) + log_trace = False + if platform == Platform.IOS: + # Temporary add log trace on iOS to debug an issue + log_trace = True + result = Tns.run(app_name=app_name, platform=platform, emulator=True, log_trace=log_trace, wait=False) strings = TnsLogs.run_messages(app_name=app_name, platform=platform, run_type=RunType.FULL, app_type=AppType.VUE, transfer_all=True) TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=360) diff --git a/tests/cli/build/android_app_bundle_tests.py b/tests/cli/build/android_app_bundle_tests.py index 15fcb386..9130e108 100644 --- a/tests/cli/build/android_app_bundle_tests.py +++ b/tests/cli/build/android_app_bundle_tests.py @@ -81,7 +81,7 @@ def test_100_run_android_app_bundle_compile_snapshot(self): uglify=True, verify=False, compile_snapshot=True) strings = ['Successfully generated snapshots', 'The build result is located at: {0}'.format(path_to_aab)] - TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=240) + TnsLogs.wait_for_log(log_file=result.log_file, string_list=strings, timeout=300) # Verify app can be deployed on emulator via nativescript # Verify app looks correct inside emulator diff --git a/tests/perf/app_size/test_app_size.py b/tests/perf/app_size/test_app_size.py index 2188f8d1..ce47b313 100644 --- a/tests/perf/app_size/test_app_size.py +++ b/tests/perf/app_size/test_app_size.py @@ -8,10 +8,10 @@ from core.base_test.tns_test import TnsTest from core.enums.os_type import OSType from core.settings import Settings +from core.utils.docker import Docker from core.utils.file_utils import File, Folder from core.utils.perf_utils import PerfUtils from core.utils.run import run -from core.utils.docker import Docker from data.templates import Template from products.nativescript.tns import Tns from products.nativescript.tns_paths import TnsPaths @@ -77,7 +77,7 @@ def test_003_js_app_apk(self): assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=16023484, tolerance=0.05) # Verify final apk size - assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=24304589, tolerance=0.03) + assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=25826703, tolerance=0.03) @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_102_js_app_ipa(self): @@ -106,7 +106,7 @@ def test_102_ng_app_apk(self): assert PerfUtils.is_value_in_range(actual=Folder.get_size(assets_snapshots), expected=27041144, tolerance=0.05) # Verify final apk size - assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=26988067, tolerance=0.03) + assert PerfUtils.is_value_in_range(actual=File.get_size(apk), expected=28482168, tolerance=0.03) @unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.') def test_102_ng_app_ipa(self): From 0a941dd143e88332c4e58edd8cf20d38253560eb Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 16:45:13 +0200 Subject: [PATCH 04/10] chore: fix travis job --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5a2c1d9b..bf291371 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ language: python python: - "2.7" before_install: + - sudo apt-get install python-xlib -y - pip install -U pip install: - python -m pip install --upgrade pip From 8f5e79b49f8474a807efbdea0bffa3b3a57f4e59 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 16:53:55 +0200 Subject: [PATCH 05/10] chore: add dependency --- requirements.txt | 3 ++- requirements_darwin.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5f8bc48e..94ddcebd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,4 +17,5 @@ subprocess32>=3.5.3 requests>=2.21.0 pytz>=2018.9 Appium-Python-Client>=0.28 -pyautogui==0.9.39 \ No newline at end of file +pyautogui==0.9.39 +python-xlib==0.25 diff --git a/requirements_darwin.txt b/requirements_darwin.txt index 5348a420..60e4401c 100644 --- a/requirements_darwin.txt +++ b/requirements_darwin.txt @@ -19,4 +19,5 @@ subprocess32>=3.5.3 requests>=2.21.0 pytz>=2018.9 Appium-Python-Client>=0.28 -pyautogui==0.9.39 \ No newline at end of file +pyautogui==0.9.39 +python-xlib==0.25 From dc6b67f8f46c706a134977748e0422bb4658cc22 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 16:56:57 +0200 Subject: [PATCH 06/10] chore: set display on travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bf291371..28a19827 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ language: python python: - "2.7" before_install: + - export DISPLAY=:0 - sudo apt-get install python-xlib -y - pip install -U pip install: From 79ef6f10a7749890508ab6ed1b5495fc18e78778 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 16:58:37 +0200 Subject: [PATCH 07/10] chore: one more expected exception to the list --- core/base_test/tns_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base_test/tns_test.py b/core/base_test/tns_test.py index be0f6a1a..24cd0418 100644 --- a/core/base_test/tns_test.py +++ b/core/base_test/tns_test.py @@ -115,7 +115,7 @@ def get_screenshots(): try: png_path = os.path.join(base_path, 'host.png') pyautogui.screenshot().save(png_path) - except (IOError, ValueError): + except (IOError, ValueError, KeyError): Log.warning('Failed to take screenshot of host os.') # get device screenshots From 69789dd3dd6bddc57decf3b6458a0f46fc417f10 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 17:01:38 +0200 Subject: [PATCH 08/10] chore: catch all exceptions --- core/base_test/tns_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base_test/tns_test.py b/core/base_test/tns_test.py index 24cd0418..fb333746 100644 --- a/core/base_test/tns_test.py +++ b/core/base_test/tns_test.py @@ -115,7 +115,7 @@ def get_screenshots(): try: png_path = os.path.join(base_path, 'host.png') pyautogui.screenshot().save(png_path) - except (IOError, ValueError, KeyError): + except Exception: Log.warning('Failed to take screenshot of host os.') # get device screenshots From bf5b7e2f97ccc7891e2c5a5369f4789781e4b88b Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 17:06:19 +0200 Subject: [PATCH 09/10] chore: fix all the things --- core/base_test/tns_test.py | 3 +-- core_tests/unit/utils/file_tests.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/core/base_test/tns_test.py b/core/base_test/tns_test.py index fb333746..f476f987 100644 --- a/core/base_test/tns_test.py +++ b/core/base_test/tns_test.py @@ -3,8 +3,6 @@ import os import unittest -import pyautogui - from core.base_test.test_context import TestContext from core.enums.os_type import OSType from core.log.log import Log @@ -113,6 +111,7 @@ def get_screenshots(): # get host snapshot base_path = os.path.join(Settings.TEST_OUT_IMAGES, TestContext.CLASS_NAME, TestContext.TEST_NAME) try: + import pyautogui png_path = os.path.join(base_path, 'host.png') pyautogui.screenshot().save(png_path) except Exception: diff --git a/core_tests/unit/utils/file_tests.py b/core_tests/unit/utils/file_tests.py index 8127aaff..0e2fb167 100644 --- a/core_tests/unit/utils/file_tests.py +++ b/core_tests/unit/utils/file_tests.py @@ -2,7 +2,6 @@ import unittest from core.base_test.test_context import TestContext -from core.base_test.tns_test import TnsTest from core.settings import Settings from core.utils.file_utils import File, Folder From c597605eb95e5d518331c1f3fc1651d94685c6c6 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Sat, 7 Dec 2019 17:08:55 +0200 Subject: [PATCH 10/10] chore: fix import --- core_tests/unit/utils/file_tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/core_tests/unit/utils/file_tests.py b/core_tests/unit/utils/file_tests.py index 0e2fb167..8127aaff 100644 --- a/core_tests/unit/utils/file_tests.py +++ b/core_tests/unit/utils/file_tests.py @@ -2,6 +2,7 @@ import unittest from core.base_test.test_context import TestContext +from core.base_test.tns_test import TnsTest from core.settings import Settings from core.utils.file_utils import File, Folder