@@ -1,7 +1,7 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
3# Unity Autopilot Test Suite
3# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014 Canonical
4+# Copyright (C) 2012, 2013, 2014, 2015 Canonical
6# This program is free software: you can redistribute it and/or modify
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
7# it under the terms of the GNU General Public License as published by
@@ -19,8 +19,6 @@
20"""Tests for Notifications"""
20"""Tests for Notifications"""
22−from __future__ import absolute_import
24from unity8 import shell
22from unity8 import shell
25from unity8.process_helpers import unlock_unity
23from unity8.process_helpers import unlock_unity
26from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
24from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
@@ -34,15 +32,9 @@ import os
34import logging
32import logging
35import signal
33import signal
36import subprocess
34import subprocess
39logger = logging.getLogger(__name__)
36logger = logging.getLogger(__name__)
41−# from __future__ import range
42−# (python3's range, is same as python2's xrange)
43−if sys.version_info < (3,):
47class NotificationsBase(UnityTestCase):
39class NotificationsBase(UnityTestCase):
48 """Base class for all notification tests that provides helper methods."""
40 """Base class for all notification tests that provides helper methods."""
@@ -118,7 +110,7 @@ class InteractiveNotificationBase(NotificationsBase):
118 """Collection of test for Interactive tests including snap decisions."""
110 """Collection of test for Interactive tests including snap decisions."""
120 def setUp(self):
112 def setUp(self):
121− super(InteractiveNotificationBase, self).setUp()
113+ super().setUp()
122 # Need to keep track when we launch the notification script.
114 # Need to keep track when we launch the notification script.
123 self._notify_proc = None
115 self._notify_proc = None
@@ -338,7 +330,7 @@ class InteractiveNotificationBase(NotificationsBase):
338 action_string = "%s,%s" % (action_id, action_label)
330 action_string = "%s,%s" % (action_id, action_label)
339 script_args.extend(['--action', action_string])
331 script_args.extend(['--action', action_string])
341− python_bin = subprocess.check_output(['which', 'python']).strip()
333+ python_bin = subprocess.check_output(['which', 'python3']).strip()
342 command = [python_bin, self._get_notify_script()] + script_args
334 command = [python_bin, self._get_notify_script()] + script_args
343 logger.info("Launching snap-decision notification as: %s", command)
335 logger.info("Launching snap-decision notification as: %s", command)
344 self._notify_proc = subprocess.Popen(
336 self._notify_proc = subprocess.Popen(
@@ -410,7 +402,7 @@ class EphemeralNotificationsTests(NotificationsBase):
410 """Collection of tests for Emphemeral notifications (non-interactive.)"""
402 """Collection of tests for Emphemeral notifications (non-interactive.)"""
412 def setUp(self):
404 def setUp(self):
413− super(EphemeralNotificationsTests, self).setUp()
405+ super().setUp()
414 # Because we are using the Notify library we need to init and un-init
406 # Because we are using the Notify library we need to init and un-init
415 # otherwise we get crashes.
407 # otherwise we get crashes.
416 Notify.init("Autopilot Ephemeral Notification Tests")
408 Notify.init("Autopilot Ephemeral Notification Tests")