on xenial help sign in
Fix flake8 warnings
commitf7eb3eea5792fb0f1d4e38da290519c0a32512e7 authorMichał Sawicz <michal.sawicz@canonical.com> dateThu 16 Apr 2015, 16:48 (12 years ago) parent7478eb8
14 files changed+70−50
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py−2 tests/autopilot/unity8/fixture_setup.py+2 tests/autopilot/unity8/greeter/tests/__init__.py+3−1 tests/autopilot/unity8/greeter/tests/test_args.py+4−2 tests/autopilot/unity8/indicators/__init__.py+5−4 tests/autopilot/unity8/indicators/tests/__init__.py+1 tests/autopilot/unity8/indicators/tests/test_action_latency.py+21−18 tests/autopilot/unity8/shell/emulators/dash.py+15−10 tests/autopilot/unity8/shell/emulators/greeter.py−1 tests/autopilot/unity8/shell/emulators/tutorial.py−1 tests/autopilot/unity8/shell/tests/__init__.py+1 tests/autopilot/unity8/shell/tests/test_lock_screen.py+4−4 tests/autopilot/unity8/shell/tests/test_notifications.py+14−6 tests/autopilot/unity8/shell/tests/test_tutorial.py−1
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py−2
@@ -22,9 +22,7 @@
2222import logging
2323import os
2424
25−from autopilot.matchers import Eventually
2625from autopilot.platform import model
27−from testtools.matchers import Equals
2826
2927from unity8 import process_helpers
3028from unity8.application_lifecycle import tests
tests/autopilot/unity8/fixture_setup.py+2
@@ -31,6 +31,7 @@ from unity8.shell import emulators
3131
3232logger = logging.getLogger(__name__)
3333
34+
3435class LaunchDashApp(fixtures.Fixture):
3536
3637 """Fixture to launch the Dash app."""
@@ -102,6 +103,7 @@ class DisplayRotationLock(fixtures.Fixture):
102103 ]
103104 subprocess.check_output(command)
104105
106+
105107class LaunchMockIndicatorService(fixtures.Fixture):
106108
107109 """Fixture to launch the indicator test service."""
tests/autopilot/unity8/greeter/tests/__init__.py+3−1
@@ -20,7 +20,9 @@
2020from unity8.shell.emulators import main_window as main_window_emulator
2121from unity8.shell.tests import UnityTestCase
2222
23+
2324class GreeterTestCase(UnityTestCase):
2425 def get_shell(self, unity_proxy):
25− main_window = unity_proxy.select_single(main_window_emulator.QQuickView)
26+ main_window = \
27+ unity_proxy.select_single(main_window_emulator.QQuickView)
2628 return main_window.select_single('Shell')
tests/autopilot/unity8/greeter/tests/test_args.py+4−2
@@ -19,6 +19,7 @@
1919
2020from unity8.greeter.tests import GreeterTestCase
2121
22+
2223class GreeterArgsTest(GreeterTestCase):
2324
2425 DEFAULT_SHELL_MODE = 'full-greeter'
@@ -43,8 +44,9 @@ class GreeterArgsTest(GreeterTestCase):
4344 unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
4445 shell = self.get_shell(unity_proxy)
4546 self.assertTrue(shell.testShellMode == self.DEFAULT_SHELL_MODE,
46− "Shell mode was {} but should have been {}".format(
47− shell.testShellMode, self.DEFAULT_SHELL_MODE))
47+ "Shell mode was {} but should have been {}"
48+ .format(shell.testShellMode,
49+ self.DEFAULT_SHELL_MODE))
4850
4951 def test_shell_mode(self):
5052 unity_proxy = self.launch_unity(mode='shell')
tests/autopilot/unity8/indicators/__init__.py+5−4
@@ -19,7 +19,6 @@ import ubuntuuitoolkit
1919from autopilot import introspection
2020
2121from unity8.shell import emulators
22−from unity8 import fixture_setup
2322
2423
2524class IndicatorPage(emulators.UnityEmulatorBase):
@@ -34,6 +33,7 @@ class IndicatorPage(emulators.UnityEmulatorBase):
3433 def validate_dbus_object(cls, path, state):
3534 return False
3635
36+
3737class Indicator():
3838
3939 def __init__(self, main_window, name):
@@ -98,7 +98,8 @@ class Indicator():
9898class DisplayIndicator(Indicator):
9999
100100 def __init__(self, main_window):
101− super(DisplayIndicator, self).__init__(main_window, 'indicator-rotation-lock')
101+ super(DisplayIndicator, self).__init__(main_window,
102+ 'indicator-rotation-lock')
102103 self._main_window = main_window
103104
104105
@@ -189,7 +190,7 @@ class Slider(emulators.UnityEmulatorBase):
189190 stop_x = x
190191
191192 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)
192− self.value.wait_for(self.minimumValue, timeout);
193+ self.value.wait_for(self.minimumValue, timeout)
193194
194195 def slide_right(self, timeout=10):
195196 x, y, width, height = self.globalRect
@@ -200,4 +201,4 @@ class Slider(emulators.UnityEmulatorBase):
200201 stop_x = x + width
201202
202203 self.pointing_device.drag(start_x, start_y, stop_x, stop_y, rate)
203− self.value.wait_for(self.maximumValue, timeout);
204+ self.value.wait_for(self.maximumValue, timeout)
tests/autopilot/unity8/indicators/tests/__init__.py+1
@@ -31,6 +31,7 @@ class IndicatorTestCase(tests.UnityTestCase):
3131 self.unity_proxy = self.launch_unity()
3232 process_helpers.unlock_unity(self.unity_proxy)
3333
34+
3435class DeviceIndicatorTestCase(IndicatorTestCase):
3536
3637 def setUp(self):
tests/autopilot/unity8/indicators/tests/test_action_latency.py+21−18
@@ -21,19 +21,16 @@ from testscenarios import multiply_scenarios
2121from unity8 import (
2222 fixture_setup,
2323 indicators,
24− process_helpers
2524)
26−from unity8.shell import tests
2725from unity8.indicators import tests
2826
2927from autopilot.matchers import Eventually
3028from testtools.matchers import Equals, NotEquals
31−import time
3229
3330
3431class TestIndicatorBaseTestCase(tests.IndicatorTestCase):
3532
36− scenarios = [ tests.IndicatorTestCase.device_emulation_scenarios[0] ]
33+ scenarios = [tests.IndicatorTestCase.device_emulation_scenarios[0]]
3734
3835 def setUp(self):
3936 super(TestIndicatorBaseTestCase, self).setUp()
@@ -49,7 +46,8 @@ class TestIndicatorBaseTestCase(tests.IndicatorTestCase):
4946 self.indicator_page = self.indicator.open()
5047
5148 def launch_indicator_service(self):
52− launch_service_fixture = fixture_setup.LaunchMockIndicatorService(self.action_delay)
49+ launch_service_fixture = \
50+ fixture_setup.LaunchMockIndicatorService(self.action_delay)
5351 self.useFixture(launch_service_fixture)
5452
5553
@@ -95,6 +93,7 @@ class TestServerValueUpdate(TestIndicatorBaseTestCase):
9593 Eventually(Equals(slider.value), timeout=20)
9694 )
9795
96+
9897class TestBuffering(TestIndicatorBaseTestCase):
9998
10099 """Test that switching multiple times will buffer activations
@@ -107,11 +106,11 @@ class TestBuffering(TestIndicatorBaseTestCase):
107106
108107 switch = self.indicator_page.get_switcher()
109108 switch.change_state()
110− intermediate_value = switch.checked;
109+ intermediate_value = switch.checked
111110
112111 # will buffer change until it receives the change from server
113112 switch.change_state()
114− final_value = switch.checked;
113+ final_value = switch.checked
115114
116115 # backend will respond to first switch.
117116 switch_menu = self.indicator_page.get_switch_menu()
@@ -121,7 +120,8 @@ class TestBuffering(TestIndicatorBaseTestCase):
121120 )
122121 # The buffered activation should have gone to server now.
123122
124− # front-end should not change as a result of server update while it is buffered
123+ # front-end should not change as a result of server update
124+ # while it is buffered
125125 self.assertThat(
126126 switch.checked,
127127 Equals(final_value)
@@ -142,15 +142,15 @@ class TestBuffering(TestIndicatorBaseTestCase):
142142 def test_slider_buffers_activations(self):
143143
144144 slider = self.indicator_page.get_slider()
145− original_value = slider.value;
145+ original_value = slider.value
146146 slider.slide_left()
147147
148148 # will buffer change until it receives the change from server
149149 slider.slide_right()
150− final_value = slider.value;
150+ final_value = slider.value
151151
152− # backend will respond to first slider. Since it's a live slider it'll probably
153− # be a random value along the slide.
152+ # backend will respond to first slider. Since it's a live slider
153+ # it'll probably be a random value along the slide.
154154 slider_menu = self.indicator_page.get_slider_menu()
155155 self.assertThat(
156156 slider_menu.serverValue,
@@ -163,7 +163,8 @@ class TestBuffering(TestIndicatorBaseTestCase):
163163 NotEquals(final_value)
164164 )
165165
166− # front-end should not change as a result of server update while it is buffered
166+ # front-end should not change as a result of server update
167+ # while it is buffered
167168 self.assertThat(
168169 slider.value,
169170 Equals(final_value)
@@ -189,17 +190,18 @@ class TestClientRevertsToServerValue(TestIndicatorBaseTestCase):
189190
190191 See https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1390136 .
191192 """
192− action_delay = -1 # never action.
193+ action_delay = -1 # never action.
193194
194195 def test_switch_reverts_on_late_response(self):
195196
196197 switch = self.indicator_page.get_switcher()
197198 switch_menu = self.indicator_page.get_switch_menu()
198199
199− original_value = switch.checked;
200+ original_value = switch.checked
200201 switch.change_state()
201202
202− # switch should revert to original value after 5 seconds (30 seconds in real usage)
203+ # switch should revert to original value after 5 seconds
204+ # (30 seconds in real usage)
203205 self.assertThat(
204206 switch.checked,
205207 Eventually(Equals(original_value), timeout=20)
@@ -216,10 +218,11 @@ class TestClientRevertsToServerValue(TestIndicatorBaseTestCase):
216218 slider = self.indicator_page.get_slider()
217219 slider_menu = self.indicator_page.get_slider_menu()
218220
219− original_value = slider.value;
221+ original_value = slider.value
220222 slider.slide_left()
221223
222− # slider should revert to original value after 5 seconds (30 seconds in real usage)
224+ # slider should revert to original value after 5 seconds
225+ # (30 seconds in real usage)
223226 self.assertThat(
224227 slider.value,
225228 Eventually(Equals(original_value), timeout=20)
tests/autopilot/unity8/shell/emulators/dash.py+15−10
@@ -92,7 +92,7 @@ class Dash(emulators.UnityEmulatorBase):
9292 aux = self.dash_content_list.get_children_by_type('QQuickItem')[0]
9393 for l in aux.get_children_by_type('QQuickLoader'):
9494 if (l.scopeId == scope_id):
95− return l;
95+ return l
9696 raise emulators.UnityEmulatorException(
9797 'No scope found with id {0}'.format(scope_id))
9898 except dbus.StateNotFoundError:
@@ -100,7 +100,7 @@ class Dash(emulators.UnityEmulatorBase):
100100 'No scope found with id {0}'.format(scope_id))
101101
102102 def _get_scope_from_loader(self, loader):
103− return loader.wait_select_single('GenericScopeView');
103+ return loader.wait_select_single('GenericScopeView')
104104
105105 def _open_scope_scrolling(self, scope_loader):
106106 scroll = self._get_scroll_direction(scope_loader)
@@ -132,7 +132,7 @@ class Dash(emulators.UnityEmulatorBase):
132132 # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
133133 rate = 10
134134 divisions = 5
135− jump = ( width / divisions ) // rate * rate
135+ jump = (width / divisions) // rate * rate
136136 start_x = x + jump
137137 stop_x = x + jump * (divisions - 1)
138138 start_y = stop_y = y + 1
@@ -148,7 +148,7 @@ class Dash(emulators.UnityEmulatorBase):
148148 # Workarounds https://bugs.launchpad.net/mir/+bug/1399690
149149 rate = 10
150150 divisions = 5
151− jump = ( width / divisions ) // rate * rate
151+ jump = (width / divisions) // rate * rate
152152 start_x = x + jump * (divisions - 1)
153153 stop_x = x + jump
154154 start_y = stop_y = y + 1
@@ -157,16 +157,19 @@ class Dash(emulators.UnityEmulatorBase):
157157
158158 def enter_search_query(self, query):
159159 current_header = self._get_current_page_header()
160− search_button = current_header.select_single(objectName="search_header_button")
161− self.pointing_device.move(search_button.globalRect.x + search_button.width / 2,
162− search_button.globalRect.y + search_button.height / 2)
160+ search_button = \
161+ current_header.select_single(objectName="search_header_button")
162+ self.pointing_device.move(
163+ search_button.globalRect.x + search_button.width / 2,
164+ search_button.globalRect.y + search_button.height / 2)
163165 self.pointing_device.click()
164166 headerContainer = current_header.select_single(
165167 objectName="headerContainer")
166168 headerContainer.contentY.wait_for(0)
167169 search_text_field = self._get_search_text_field()
168170 search_text_field.write(query)
169− self.select_single(objectName="processingIndicator").visible.wait_for(False)
171+ self.select_single(objectName="processingIndicator")\
172+ .visible.wait_for(False)
170173
171174 def _get_search_text_field(self):
172175 page_header = self._get_current_page_header()
@@ -217,13 +220,15 @@ class GenericScopeView(emulators.UnityEmulatorBase):
217220
218221 """
219222 category_element = self._get_category_element(category)
220− icon = category_element.wait_select_single('AbstractButton', title=title)
223+ icon = category_element.wait_select_single('AbstractButton',
224+ title=title)
221225 self.pointing_device.click_object(icon)
222226
223227 def _get_category_element(self, category):
224228 try:
225229 return self.wait_select_single(
226− 'DashCategoryBase', objectName='dashCategory{}'.format(category))
230+ 'DashCategoryBase',
231+ objectName='dashCategory{}'.format(category))
227232 except dbus.StateNotFoundError:
228233 raise emulators.UnityEmulatorException(
229234 'No category found with name {}'.format(category))
tests/autopilot/unity8/shell/emulators/greeter.py−1
@@ -42,7 +42,6 @@ class Greeter(UnityEmulatorBase):
4242
4343 raise AssertionError("Greeter cover page still up after 10s")
4444
45−
4645 def swipe(self):
4746 """Swipe the greeter screen away."""
4847 self.waiting.wait_for(False)
tests/autopilot/unity8/shell/emulators/tutorial.py−1
@@ -18,7 +18,6 @@
1818#
1919
2020import logging
21−import time
2221
2322import ubuntuuitoolkit
2423
tests/autopilot/unity8/shell/tests/__init__.py+1
@@ -65,6 +65,7 @@ UNITYSHELL_GSETTINGS_PATH = "/org/compiz/profiles/unity/plugins/unityshell/"
6565UNITYSHELL_LAUNCHER_KEY = "launcher-hide-mode"
6666UNITYSHELL_LAUNCHER_MODE = 1 # launcher hidden
6767
68+
6869def _get_device_emulation_scenarios(devices='All'):
6970 nexus4 = ('Desktop Nexus 4',
7071 dict(app_width=768, app_height=1280, grid_unit_px=18))
tests/autopilot/unity8/shell/tests/test_lock_screen.py+4−4
@@ -41,7 +41,7 @@ class TestLockscreen(UnityTestCase):
4141
4242 if not greeter.tabletMode:
4343 greeter.swipe()
44− lockscreen = self._wait_for_lockscreen()
44+ self._wait_for_lockscreen()
4545 self.main_window.enter_pin_code("1234")
4646 else:
4747 self._enter_prompt_passphrase("1234\n")
@@ -56,7 +56,7 @@ class TestLockscreen(UnityTestCase):
5656
5757 if not greeter.tabletMode:
5858 greeter.swipe()
59− lockscreen = self._wait_for_lockscreen()
59+ self._wait_for_lockscreen()
6060 self._enter_pin_passphrase("password")
6161 else:
6262 self._enter_prompt_passphrase("password")
@@ -70,7 +70,7 @@ class TestLockscreen(UnityTestCase):
7070
7171 if not greeter.tabletMode:
7272 greeter.swipe()
73− lockscreen = self._wait_for_lockscreen()
73+ self._wait_for_lockscreen()
7474 self.main_window.enter_pin_code("4321")
7575 pinentryField = self.main_window.get_pinentryField()
7676 self.assertThat(pinentryField.text, Eventually(Equals("")))
@@ -88,7 +88,7 @@ class TestLockscreen(UnityTestCase):
8888
8989 if not greeter.tabletMode:
9090 greeter.swipe()
91− lockscreen = self._wait_for_lockscreen()
91+ self._wait_for_lockscreen()
9292 self._enter_pin_passphrase("foobar")
9393 pinentryField = self.main_window.get_pinentryField()
9494 self.assertThat(pinentryField.text, Eventually(Equals("")))
tests/autopilot/unity8/shell/tests/test_notifications.py+14−6
@@ -127,7 +127,7 @@ class InteractiveNotificationBase(NotificationsBase):
127127 actions = [("action_id", "dummy")]
128128 hints = [
129129 ("x-canonical-switch-to-application", "true"),
130− ("x-canonical-secondary-icon","dialer")
130+ ("x-canonical-secondary-icon", "dialer")
131131 ]
132132
133133 self._create_interactive_notification(
@@ -150,7 +150,9 @@ class InteractiveNotificationBase(NotificationsBase):
150150 self.assert_notification_action_id_was_called('action_id')
151151
152152 def test_sd_one_over_two_layout(self):
153− """Snap-decision with three actions should use one-over two button layout."""
153+ """Snap-decision with three actions should use
154+ one-over two button layout.
155+ """
154156 unity_proxy = self.launch_unity()
155157 unlock_unity(unity_proxy)
156158
@@ -189,7 +191,9 @@ class InteractiveNotificationBase(NotificationsBase):
189191 self.assert_notification_action_id_was_called("action_accept")
190192
191193 def test_modal_sd_without_greeter(self):
192− """Snap-decision should block input to shell without greeter/lockscreen."""
194+ """Snap-decision should block input to shell
195+ without greeter/lockscreen.
196+ """
193197 unity_proxy = self.launch_unity()
194198 unlock_unity(unity_proxy)
195199
@@ -236,7 +240,9 @@ class InteractiveNotificationBase(NotificationsBase):
236240 self.assert_notification_action_id_was_called("action_accept")
237241
238242 def test_modal_sd_with_greeter(self):
239− """A snap-decision should block input to the greeter/lockscreen beneath it."""
243+ """A snap-decision should block input to the
244+ greeter/lockscreen beneath it.
245+ """
240246 self.launch_unity()
241247
242248 summary = "Incoming file"
@@ -350,7 +356,9 @@ class InteractiveNotificationBase(NotificationsBase):
350356 raise RuntimeError("Call to script failed with: %s" % error_output)
351357
352358 def _get_notify_script(self):
353− """Returns the path to the interactive notification creation script."""
359+ """Returns the path to the interactive notification
360+ creation script.
361+ """
354362 file_path = "../../emulators/create_interactive_notification.py"
355363
356364 the_path = os.path.abspath(
@@ -454,7 +462,7 @@ class EphemeralNotificationsTests(NotificationsBase):
454462
455463 summary = "Upload of image completed"
456464 icon_path = self._get_icon_path('applicationIcons/facebook.png')
457− hints=[]
465+ hints = []
458466
459467 notification = shell.create_ephemeral_notification(
460468 summary,
tests/autopilot/unity8/shell/tests/test_tutorial.py−1
@@ -25,7 +25,6 @@ from unity8.shell import (
2525 tests
2626)
2727# unused import to load the tutorial emulators custom proxy objects.
28−from unity8.shell.emulators import tutorial # NOQA
2928
3029
3130class TutorialTestCase(tests.UnityTestCase):