|
17 | 17 | from products.nativescript.tns import Tns
|
18 | 18 |
|
19 | 19 |
|
20 |
| -# noinspection PyBroadException |
| 20 | +# noinspection PyBroadException,PyUnresolvedReferences |
21 | 21 | class TnsTest(unittest.TestCase):
|
22 | 22 | @classmethod
|
23 | 23 | def setUpClass(cls):
|
@@ -72,20 +72,21 @@ def tearDown(self):
|
72 | 72 | Gradle.kill()
|
73 | 73 | Process.kill_all_in_context()
|
74 | 74 | TnsTest.restore_files()
|
75 |
| - # Analise test result |
76 |
| - if Settings.PYTHON_VERSION < 3: |
77 |
| - # noinspection PyUnresolvedReferences |
78 |
| - result = self._resultForDoCleanups |
79 |
| - else: |
80 |
| - # noinspection PyUnresolvedReferences |
81 |
| - result = self._outcome.result |
82 | 75 |
|
83 |
| - outcome = 'FAILED' |
84 |
| - if result.errors == [] and result.failures == []: |
85 |
| - outcome = 'PASSED' |
86 |
| - else: |
| 76 | + # Get outcome |
| 77 | + if hasattr(self, '_outcome'): # Python 3.4+ |
| 78 | + result = self.defaultTestResult() # these 2 methods have no side effects |
| 79 | + self._feedErrorsToResult(result, self._outcome.errors) |
| 80 | + else: # Python 3.2 - 3.3 or 3.0 - 3.1 and 2.7 |
| 81 | + result = getattr(self, '_outcomeForDoCleanups', self._resultForDoCleanups) |
| 82 | + |
| 83 | + # Take screen on test fail |
| 84 | + if result.errors or result.failures: |
87 | 85 | self.get_screenshots()
|
88 | 86 | self.archive_apps()
|
| 87 | + outcome = 'FAILED' |
| 88 | + else: |
| 89 | + outcome = 'PASSED' |
89 | 90 | Log.test_end(test_name=TestContext.TEST_NAME, outcome=outcome)
|
90 | 91 |
|
91 | 92 | @classmethod
|
@@ -113,7 +114,10 @@ def get_screenshots():
|
113 | 114 | try:
|
114 | 115 | import pyautogui
|
115 | 116 | png_path = os.path.join(base_path, 'host.png')
|
| 117 | + File.delete(png_path) |
| 118 | + Folder.create(folder=os.path.dirname(png_path)) |
116 | 119 | pyautogui.screenshot().save(png_path)
|
| 120 | + Log.info("Saved host os screen at {0}".format(png_path)) |
117 | 121 | except Exception:
|
118 | 122 | Log.warning('Failed to take screenshot of host os.')
|
119 | 123 |
|
|
0 commit comments