--- a/testing/marionette/client/docs/conf.py
+++ b/testing/marionette/client/docs/conf.py
@@ -6,16 +6,18 @@
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
+from __future__ import absolute_import
+
import os
import sys
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# sys.path.insert(0, os.path.abspath('.'))
--- a/testing/marionette/client/marionette_driver/__init__.py
+++ b/testing/marionette/client/marionette_driver/__init__.py
@@ -1,14 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
__version__ = '2.5.0'
+from __future__ import absolute_import
+
from marionette_driver import (
addons,
by,
date_time_value,
decorators,
errors,
expected,
geckoinstance,
--- a/testing/marionette/client/marionette_driver/addons.py
+++ b/testing/marionette/client/marionette_driver/addons.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from . import errors
__all__ = ["Addons", "AddonInstallException"]
class AddonInstallException(errors.MarionetteException):
pass
--- a/testing/marionette/client/marionette_driver/by.py
+++ b/testing/marionette/client/marionette_driver/by.py
@@ -8,16 +8,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
+
class By(object):
ID = "id"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
NAME = "name"
TAG_NAME = "tag name"
--- a/testing/marionette/client/marionette_driver/date_time_value.py
+++ b/testing/marionette/client/marionette_driver/date_time_value.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
class DateTimeValue(object):
"""
Interface for setting the value of HTML5 "date" and "time" input elements.
Simple usage example:
::
--- a/testing/marionette/client/marionette_driver/decorators.py
+++ b/testing/marionette/client/marionette_driver/decorators.py
@@ -1,12 +1,17 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import (
+ absolute_import,
+ print_function
+)
+
from functools import wraps
import socket
def _find_marionette_in_args(*args, **kwargs):
try:
m = [a for a in args + tuple(kwargs.values()) if hasattr(a, 'session')][0]
except IndexError:
--- a/testing/marionette/client/marionette_driver/errors.py
+++ b/testing/marionette/client/marionette_driver/errors.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import traceback
class MarionetteException(Exception):
"""Raised when a generic non-recoverable exception has occured."""
status = "webdriver error"
--- a/testing/marionette/client/marionette_driver/expected.py
+++ b/testing/marionette/client/marionette_driver/expected.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import errors
import types
from marionette import HTMLElement
"""This file provides a set of expected conditions for common use
cases when writing Marionette tests.
--- a/testing/marionette/client/marionette_driver/geckoinstance.py
+++ b/testing/marionette/client/marionette_driver/geckoinstance.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/
+from __future__ import absolute_import
+
import os
import sys
import tempfile
import time
from copy import deepcopy
import mozversion
@@ -204,17 +206,17 @@ class GeckoInstance(object):
if not app and kwargs["bin"] is not None:
app_id = mozversion.get_version(binary=kwargs["bin"])["application_id"]
app = app_ids[app_id]
instance_class = apps[app]
except (IOError, KeyError):
exc, val, tb = sys.exc_info()
msg = 'Application "{0}" unknown (should be one of {1})'
- raise NotImplementedError, msg.format(app, apps.keys()), tb
+ raise NotImplementedError(msg.format(app, apps.keys()), tb)
return instance_class(*args, **kwargs)
def start(self):
self._update_profile()
self.runner = self.runner_class(**self._get_runner_args())
self.runner.start()
@@ -347,17 +349,17 @@ class FennecInstance(GeckoInstance):
self.runner = self.runner_class(**self._get_runner_args())
try:
if self.connect_to_running_emulator:
self.runner.device.connect()
self.runner.start()
except Exception as e:
exc, val, tb = sys.exc_info()
message = "Error possibly due to runner or device args: {}"
- raise exc, message.format(e.message), tb
+ raise (exc, message.format(e.message), tb)
# gecko_log comes from logcat when running with device/emulator
logcat_args = {
"filterspec": "Gecko",
"serial": self.runner.device.dm._deviceSerial
}
if self.gecko_log == "-":
logcat_args["stream"] = sys.stdout
else:
--- a/testing/marionette/client/marionette_driver/gestures.py
+++ b/testing/marionette/client/marionette_driver/gestures.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette import MultiActions, Actions
def smooth_scroll(marionette_session, start_element, axis, direction,
length, increments=None, wait_period=None, scroll_back=None):
"""
:param axis: y or x
:param direction: 0 for positive, and -1 for negative
--- a/testing/marionette/client/marionette_driver/keys.py
+++ b/testing/marionette/client/marionette_driver/keys.py
@@ -8,16 +8,18 @@
# http //www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import absolute_import
+
class Keys(object):
NULL = u'\ue000'
CANCEL = u'\ue001' # ^break
HELP = u'\ue002'
BACK_SPACE = u'\ue003'
TAB = u'\ue004'
--- a/testing/marionette/client/marionette_driver/localization.py
+++ b/testing/marionette/client/marionette_driver/localization.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
class L10n(object):
"""An API which allows Marionette to handle localized content.
The `localization`_ of UI elements in Gecko based applications is done via
entities and properties. For static values entities are used, which are located
in .dtd files. Whereby for dynamically updated content the values come from
.property files. Both types of elements can be identifed via a unique id,
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import base64
import datetime
import json
import os
import socket
import sys
import time
import traceback
@@ -634,17 +636,17 @@ class Marionette(object):
except socket.timeout:
# Something went wrong with starting up Marionette server. Given
# that the process will not quit itself, force a shutdown immediately.
self.cleanup()
msg = "Process killed after {}s because no connection to Marionette "\
"server could be established. Check gecko.log for errors"
_, _, tb = sys.exc_info()
- raise IOError, msg.format(timeout), tb
+ raise IOError(msg.format(timeout), tb)
def cleanup(self):
if self.session is not None:
try:
self.delete_session()
except (errors.MarionetteException, IOError):
# These exceptions get thrown if the Marionette server
# hit an exception/died or the connection died. We can
@@ -788,17 +790,17 @@ class Marionette(object):
frame, and is only called via the `@do_process_check` decorator.
"""
exc, val, tb = sys.exc_info()
# If the application hasn't been launched by Marionette no further action can be done.
# In such cases we simply re-throw the exception.
if not self.instance:
- raise exc, val, tb
+ raise(exc, val, tb)
else:
# Somehow the socket disconnected. Give the application some time to shutdown
# itself before killing the process.
returncode = self.instance.runner.wait(timeout=self.DEFAULT_SHUTDOWN_TIMEOUT)
if returncode is None:
message = ('Process killed because the connection to Marionette server is '
@@ -816,17 +818,17 @@ class Marionette(object):
message = 'Process crashed (Exit code: {returncode})'
else:
message = 'Process has been unexpectedly closed (Exit code: {returncode})'
self.delete_session(send_request=False, reset_session_id=True)
message += ' (Reason: {reason})'
- raise IOError, message.format(returncode=returncode, reason=val), tb
+ raise IOError(message.format(returncode=returncode, reason=val), tb)
@staticmethod
def convert_keys(*string):
typing = []
for val in string:
if isinstance(val, Keys):
typing.append(val)
elif isinstance(val, int):
@@ -1146,17 +1148,17 @@ class Marionette(object):
try:
timeout = self.DEFAULT_SHUTDOWN_TIMEOUT + self.DEFAULT_STARTUP_TIMEOUT
self.raise_for_port(timeout=timeout)
except socket.timeout:
if self.instance.runner.returncode is not None:
exc, val, tb = sys.exc_info()
self.cleanup()
- raise exc, "Requested restart of the application was aborted", tb
+ raise exc("Requested restart of the application was aborted", tb)
else:
self.delete_session()
self.instance.restart(clean=clean)
self.raise_for_port(timeout=self.DEFAULT_STARTUP_TIMEOUT)
if cause not in (None, "restart"):
raise errors.MarionetteException("Unexpected shutdown reason '{}' for "
--- a/testing/marionette/client/marionette_driver/selection.py
+++ b/testing/marionette/client/marionette_driver/selection.py
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
class SelectionManager(object):
'''Interface for manipulating the selection and carets of the element.
We call the blinking cursor (nsCaret) as cursor, and call AccessibleCaret as
caret for short.
Simple usage example:
--- a/testing/marionette/client/marionette_driver/timeout.py
+++ b/testing/marionette/client/marionette_driver/timeout.py
@@ -1,13 +1,15 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import errors
DEFAULT_SCRIPT_TIMEOUT = 30
DEFAULT_PAGE_LOAD_TIMEOUT = 300
DEFAULT_IMPLICIT_WAIT_TIMEOUT = 0
--- a/testing/marionette/client/marionette_driver/transport.py
+++ b/testing/marionette/client/marionette_driver/transport.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import json
import socket
import sys
import time
class SocketTimeout(object):
def __init__(self, socket, timeout):
@@ -199,17 +201,17 @@ class TcpTransport(object):
with SocketTimeout(self._sock, 60.0):
# first packet is always a JSON Object
# which we can use to tell which protocol level we are at
raw = self.receive(unmarshal=False)
except socket.timeout:
msg = "Connection attempt failed because no data has been received over the socket: {}"
exc, val, tb = sys.exc_info()
- raise exc, msg.format(val), tb
+ raise exc(msg.format(val), tb)
hello = json.loads(raw)
application_type = hello.get("applicationType")
protocol = hello.get("marionetteProtocol")
if application_type != "gecko":
raise ValueError("Application type '{}' is not supported".format(application_type))
--- a/testing/marionette/client/marionette_driver/wait.py
+++ b/testing/marionette/client/marionette_driver/wait.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import collections
import errors
import sys
import time
DEFAULT_TIMEOUT = 5
DEFAULT_INTERVAL = 0.1
--- a/testing/marionette/client/setup.py
+++ b/testing/marionette/client/setup.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import os
import re
from setuptools import setup, find_packages
THIS_DIR = os.path.dirname(os.path.realpath(__name__))
def read(*parts):
--- a/testing/marionette/harness/marionette_harness/__init__.py
+++ b/testing/marionette/harness/marionette_harness/__init__.py
@@ -1,14 +1,16 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
__version__ = '4.3.0'
+from __future__ import absolute_import
+
from .marionette_test import (
CommonTestCase,
expectedFailure,
MarionetteTestCase,
parameterized,
run_if_e10s,
run_if_manage_instance,
skip,
--- a/testing/marionette/harness/marionette_harness/marionette_test/__init__.py
+++ b/testing/marionette/harness/marionette_harness/marionette_test/__init__.py
@@ -1,14 +1,15 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
__version__ = '3.1.0'
+from __future__ import absolute_import
from unittest.case import (
expectedFailure,
skip,
SkipTest,
)
from .decorators import (
--- a/testing/marionette/harness/marionette_harness/marionette_test/decorators.py
+++ b/testing/marionette/harness/marionette_harness/marionette_test/decorators.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import functools
import types
from unittest.case import (
SkipTest,
)
--- a/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
+++ b/testing/marionette/harness/marionette_harness/marionette_test/testcases.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import imp
import re
import sys
import time
import types
import unittest
import warnings
import weakref
--- a/testing/marionette/harness/marionette_harness/runner/__init__.py
+++ b/testing/marionette/harness/marionette_harness/runner/__init__.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from .base import (
BaseMarionetteArguments,
BaseMarionetteTestRunner,
Marionette,
MarionetteTest,
MarionetteTestResult,
MarionetteTextTestRunner,
TestManifest,
--- a/testing/marionette/harness/marionette_harness/runner/base.py
+++ b/testing/marionette/harness/marionette_harness/runner/base.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import json
import os
import random
import re
import socket
import sys
import time
import traceback
@@ -651,17 +653,17 @@ class BaseMarionetteTestRunner(object):
if not os.path.exists(path):
raise IOError('--testvars file {} does not exist'.format(path))
try:
with open(path) as f:
data.append(json.loads(f.read()))
except ValueError as e:
exc, val, tb = sys.exc_info()
msg = "JSON file ({0}) is not properly formatted: {1}"
- raise exc, msg.format(os.path.abspath(path), e.message), tb
+ raise exc(msg.format(os.path.abspath(path), e.message), tb)
return data
@property
def capabilities(self):
if self._capabilities:
return self._capabilities
self.marionette.start_session()
@@ -762,17 +764,17 @@ class BaseMarionetteTestRunner(object):
try:
# Establish a socket connection so we can vertify the data come back
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect((host, int(port)))
connection.close()
except Exception as e:
exc, val, tb = sys.exc_info()
msg = "Connection attempt to {0}:{1} failed with error: {2}"
- raise exc, msg.format(host, port, e), tb
+ raise exc(msg.format(host, port, e), tb)
if self.workspace:
kwargs['workspace'] = self.workspace_path
if self.headless:
kwargs['headless'] = True
return kwargs
def record_crash(self):
@@ -912,17 +914,17 @@ class BaseMarionetteTestRunner(object):
# raise only the exception if we were not interrupted
if not interrupted:
raise
finally:
self.cleanup()
# reraise previous interruption now
if interrupted:
- raise interrupted[0], interrupted[1], interrupted[2]
+ raise(interrupted[0], interrupted[1], interrupted[2])
def _print_summary(self, tests):
self.logger.info('\nSUMMARY\n-------')
self.logger.info('passed: {}'.format(self.passed))
if self.unexpected_successes == 0:
self.logger.info('failed: {}'.format(self.failed))
else:
self.logger.info(
--- a/testing/marionette/harness/marionette_harness/runner/httpd.py
+++ b/testing/marionette/harness/marionette_harness/runner/httpd.py
@@ -3,16 +3,20 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""Specialisation of wptserver.server.WebTestHttpd for testing
Marionette.
"""
+from __future__ import (
+ absolute_import,
+ print_function
+)
import argparse
import os
import select
import sys
import time
import urlparse
--- a/testing/marionette/harness/marionette_harness/runner/mixins/__init__.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/__init__.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from .browsermob import (
BrowserMobProxyTestCaseMixin,
BrowserMobProxyArguments,
BrowserMobTestCase,
)
from .window_manager import (
WindowManagerMixin,
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/__init__.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/__init__.py
@@ -1,6 +1,8 @@
__version__ = '0.5.0'
+from __future__ import absolute_import
+
from .server import Server
from .client import Client
__all__ = ['Server', 'Client', 'browsermobproxy']
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/client.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/client.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
import requests
try:
from urllib.parse import urlencode, unquote
except ImportError:
from urllib import urlencode, unquote
import json
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/server.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/server.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
import os
import platform
import socket
import subprocess
import time
from .client import Client
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/webdriver_event_listener.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/browsermobproxy/webdriver_event_listener.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from selenium.webdriver.support.abstract_event_listener import AbstractEventListener
class WebDriverEventListener(AbstractEventListener):
def __init__(self, client, refs={}):
self.client = client
self.hars = []
self.refs = refs
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/conf.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/docs/conf.py
@@ -6,16 +6,18 @@
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.
+from __future__ import absolute_import
+
import sys, os
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../'))
# -- General configuration -----------------------------------------------------
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/setup.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/setup.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from setuptools import setup, find_packages
setup(name='browsermob-proxy',
version='0.6.0',
description='A library for interacting with the Browsermob Proxy',
author='David Burns',
author_email='david.burns at theautomatedtester dot co dot uk',
url='http://oss.theautomatedtester.co.uk/browsermob-proxy-py',
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_client.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_client.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
import os.path
import pytest
import sys
def setup_module(module):
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_remote.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_remote.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from selenium import webdriver
import selenium.webdriver.common.desired_capabilities
import os
import sys
import time
import pytest
def setup_module(module):
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_webdriver.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py/test/test_webdriver.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from selenium import webdriver
import selenium.webdriver.common.desired_capabilities
from selenium.webdriver.common.proxy import Proxy
import os
import sys
import copy
import time
import pytest
--- a/testing/marionette/harness/marionette_harness/runner/mixins/browsermob.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/browsermob.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import os
from browsermobproxy import Server
from marionette_harness import MarionetteTestCase
class BrowserMobProxyArguments(object):
name = 'Browsermob Proxy'
--- a/testing/marionette/harness/marionette_harness/runner/mixins/window_manager.py
+++ b/testing/marionette/harness/marionette_harness/runner/mixins/window_manager.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import sys
from marionette_driver import By, Wait
class WindowManagerMixin(object):
_menu_item_new_tab = (By.ID, "menu_newNavigatorTab")
@@ -63,17 +65,17 @@ class WindowManagerMixin(object):
try:
if callable(trigger):
trigger()
elif trigger == 'menu':
with self.marionette.using_context("chrome"):
self.marionette.find_element(*self._menu_item_new_tab).click()
except Exception:
exc, val, tb = sys.exc_info()
- raise exc, 'Failed to trigger opening a new tab: {}'.format(val), tb
+ raise exc('Failed to trigger opening a new tab: {}'.format(val), tb)
else:
Wait(self.marionette).until(
lambda mn: len(mn.window_handles) == len(current_tabs) + 1,
message="No new tab has been opened"
)
[new_tab] = list(set(self.marionette.window_handles) - set(current_tabs))
@@ -94,17 +96,17 @@ class WindowManagerMixin(object):
try:
if callable(trigger):
trigger()
else:
with self.marionette.using_context("chrome"):
self.marionette.execute_script("window.open();")
except Exception:
exc, val, tb = sys.exc_info()
- raise exc, 'Failed to trigger opening a new window: {}'.format(val), tb
+ raise exc('Failed to trigger opening a new window: {}'.format(val), tb)
else:
Wait(self.marionette).until(
lambda mn: len(mn.chrome_window_handles) == len(current_windows) + 1,
message="No new window has been opened"
)
[new_window] = list(set(self.marionette.chrome_window_handles) - set(current_windows))
--- a/testing/marionette/harness/marionette_harness/runner/serve.py
+++ b/testing/marionette/harness/marionette_harness/runner/serve.py
@@ -4,16 +4,21 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""Spawns necessary HTTP servers for testing Marionette in child
processes.
"""
+from __future__ import (
+ absolute_import,
+ print_function
+)
+
import argparse
import multiprocessing
import os
import sys
from collections import defaultdict
import httpd
--- a/testing/marionette/harness/marionette_harness/runtests.py
+++ b/testing/marionette/harness/marionette_harness/runtests.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import sys
import mozlog
from marionette_driver import __version__ as driver_version
from marionette_harness import (
__version__,
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/conftest.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/conftest.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import pytest
from mock import Mock, MagicMock
from marionette_driver.marionette import Marionette
from marionette_harness.runner.httpd import FixtureServer
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_httpd.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_httpd.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import json
import os
import types
import urllib2
import mozunit
import pytest
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py
@@ -1,11 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import
+
import mozunit
import pytest
from marionette_harness.runtests import MarionetteArguments
@pytest.mark.parametrize("socket_timeout", ['A', '10', '1B-', '1C2', '44.35'])
def test_parse_arg_socket_timeout(socket_timeout):
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_harness.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_harness.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import mozunit
import pytest
from mock import Mock, patch, sentinel
import marionette_harness.marionette_test as marionette_test
from marionette_harness.runtests import MarionetteTestRunner, MarionetteHarness, cli
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_runner.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import manifestparser
import mozunit
import pytest
from mock import Mock, patch, mock_open, sentinel, DEFAULT
from marionette_harness.runtests import MarionetteTestRunner
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_test_result.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_test_result.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import mozunit
import pytest
from marionette_harness import MarionetteTestResult
@pytest.fixture
def empty_marionette_testcase():
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_serve.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_serve.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import types
import mozunit
import pytest
from marionette_harness.runner import serve
from marionette_harness.runner.serve import iter_proc, iter_url
--- a/testing/marionette/harness/marionette_harness/tests/unit/single_finger_functions.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/single_finger_functions.py
@@ -1,8 +1,10 @@
+from __future__ import absolute_import
+
from marionette_driver.marionette import Actions
from marionette_driver.errors import TimeoutException
from marionette_driver.by import By
def wait_for_condition_else_raise(marionette, wait_for_condition, expected, script):
try:
wait_for_condition(lambda m: expected in m.execute_script(script))
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_accessibility.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import sys
import unittest
from marionette_driver.by import By
from marionette_driver.errors import (
ElementNotAccessibleException,
ElementNotInteractableException,
ElementClickInterceptedException,
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_addons.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import os
from marionette_driver.addons import Addons, AddonInstallException
from marionette_harness import MarionetteTestCase
here = os.path.abspath(os.path.dirname(__file__))
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_anonymous_content.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_anonymous_content.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_driver.errors import NoSuchElementException
from marionette_driver.marionette import HTMLElement
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestAnonymousNodes(WindowManagerMixin, MarionetteTestCase):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_browsermobproxy.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_browsermobproxy.py
@@ -1,10 +1,12 @@
import datetime
+from __future__ import absolute_import
+
from marionette_harness.runner import BrowserMobTestCase
class TestBrowserMobProxy(BrowserMobTestCase):
"""To run this test, you'll need to download the browsermob-proxy from
http://bmp.lightbody.net/, and then pass the path to the startup
script (typically /path/to/browsermob-proxy-2.0.0/bin/browsermob-proxy)
as the --browsermob-script argument when running runtests.py.
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_capabilities.py
@@ -1,12 +1,17 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import (
+ absolute_import,
+ print_function
+)
+
from marionette_driver.errors import SessionNotCreatedException
from marionette_harness import MarionetteTestCase
# Unlike python 3, python 2 doesn't have a proper implementation of realpath or
# samefile for Windows. However this function, which does exactly what we want,
# was added to python 2 to fix an issue with tcl installations and symlinks.
from FixTk import convert_path
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_checkbox.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_checkbox.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_harness import MarionetteTestCase
class TestCheckbox(MarionetteTestCase):
def test_selected(self):
test_html = self.marionette.absolute_url("test.html")
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_checkbox_chrome.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_checkbox_chrome.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestSelectedChrome(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_chrome.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_chrome.py
@@ -8,16 +8,18 @@
# http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.
+from __future__ import absolute_import
+
from marionette_driver import By
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class ChromeTests(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_chrome_element_css.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_harness import MarionetteTestCase
class TestChromeElementCSS(MarionetteTestCase):
def get_element_computed_style(self, element, property):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_clearing.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_driver.errors import InvalidElementStateException
from marionette_harness import MarionetteTestCase
class TestClear(MarionetteTestCase):
def testWriteableTextInputShouldClear(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_cli_arguments.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import copy
from marionette_harness import MarionetteTestCase
class TestCommandLineArguments(MarionetteTestCase):
def setUp(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
import urllib
from marionette_driver import By, errors
from marionette_harness import (
MarionetteTestCase,
run_if_e10s,
skip_if_mobile,
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click_chrome.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click_chrome.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_harness import MarionetteTestCase, WindowManagerMixin
class TestClickChrome(WindowManagerMixin, MarionetteTestCase):
def setUp(self):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click_scrolling.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click_scrolling.py
@@ -1,12 +1,14 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+from __future__ import absolute_import
+
from marionette_driver.by import By
from marionette_driver.errors import MoveTargetOutOfBoundsException
from marionette_harness import MarionetteTestCase, skip, skip_if_mobile
class TestClickScrolling(MarionetteTestCase):
--- a/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/software_update.py
+++ b/testing/marionette/puppeteer/firefox/firefox_puppeteer/api/software_update.py
@@ -363,18 +363,18 @@ class SoftwareUpdate(BaseLib):
:param update_url: URL to the update snippet
"""
import urllib2
try:
response = urllib2.urlopen(update_url)
return response.read()
except urllib2.URLError:
exc, val, tb = sys.exc_info()
- raise Exception, "Failed to retrieve update snippet '{}': {}".format(
- update_url, val), tb
+ raise Exception("Failed to retrieve update snippet '{}': {}".format(
+ update_url, val), tb)
def get_formatted_update_url(self, force=False):
"""Retrieve the formatted AUS update URL the update snippet is retrieved from.
:param force: Boolean flag to force an update check
:returns: The URL of the update snippet
"""