Bug 1428708 - [mozdevice] Add support for Python 3 r=ahal
authorAndrei H <ahutusoru@mozilla.com>
Sat, 02 Feb 2019 20:39:14 +0000
changeset 456563 5e295b971fd8c53e94525fe31f54fa0d6e9ceb27
parent 456562 4ceb95f3fa4a80374bdd53e2a89cac4e777a2fc8
child 456564 5b4294b589042588942714434fe614b93bb20ae1
push id35490
push useraiakab@mozilla.com
push dateSun, 03 Feb 2019 09:50:26 +0000
treeherdermozilla-central@12b2328eedd1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1428708
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1428708 - [mozdevice] Add support for Python 3 r=ahal Differential Revision: https://phabricator.services.mozilla.com/D17933
testing/mozbase/mozdevice/tests/conftest.py
testing/mozbase/mozdevice/tests/manifest.ini
--- a/testing/mozbase/mozdevice/tests/conftest.py
+++ b/testing/mozbase/mozdevice/tests/conftest.py
@@ -1,19 +1,17 @@
-
 from __future__ import absolute_import, print_function
 
 import sys
-
-from cStringIO import StringIO
 from random import randint, seed
 
+import mozdevice
 import pytest
-import mozdevice
 from mock import patch
+from six import StringIO
 
 # set up required module-level variables/objects
 seed(1488590)
 
 
 def random_tcp_port():
     """Returns a pseudo-random integer generated from a seed.
 
@@ -27,16 +25,17 @@ def mock_command_output(monkeypatch):
     """Monkeypatches the ADBDevice.command_output() method call.
 
     Instead of calling the concrete method implemented in adb.py::ADBDevice,
     this method simply returns a string representation of the command that was
     received.
 
     :param object monkeypatch: pytest provided fixture for mocking.
     """
+
     def command_output_wrapper(object, cmd, timeout):
         """Actual monkeypatch implementation of the comand_output method call.
 
         :param object object: placeholder object representing ADBDevice
         :param str cmd: command to be executed
         :param timeout: unused parameter to represent timeout threshold
         :returns: string - string representation of command to be executed
         """
@@ -52,16 +51,17 @@ def mock_shell_output(monkeypatch):
     """Monkeypatches the ADBDevice.shell_output() method call.
 
     Instead of returning the output of an adb call, this method will
     return appropriate string output. Content of the string output is
     in line with the calling method's expectations.
 
     :param object monkeypatch: pytest provided fixture for mocking.
     """
+
     def shell_output_wrapper(object, cmd, env=None, cwd=None, timeout=None, root=False):
         """Actual monkeypatch implementation of the shell_output method call.
 
         :param object object: placeholder object representing ADBDevice
         :param str cmd: command to be executed
         :param env: contains the environment variable
         :type env: dict or None
         :param cwd: The directory from which to execute.
@@ -87,16 +87,17 @@ def mock_shell_output(monkeypatch):
 def mock_is_path_internal_storage(monkeypatch):
     """Monkeypatches the ADBDevice.is_path_internal_storage() method call.
 
     Instead of returning the outcome of whether the path provided is
     internal storage or external, this will always return True.
 
     :param object monkeypatch: pytest provided fixture for mocking.
     """
+
     def is_path_internal_storage_wrapper(object, path, timeout=None):
         """Actual monkeypatch implementation of the is_path_internal_storage() call.
 
         :param str path: The path to test.
         :param timeout: The maximum time in
             seconds for any spawned adb process to complete before
             throwing an ADBTimeoutError.  This timeout is per adb call. The
             total time spent may exceed this value. If it is not
@@ -119,16 +120,17 @@ def mock_shell_bool(monkeypatch):
     """Monkeypatches the ADBDevice.shell_bool() method call.
 
     Instead of returning the output of an adb call, this method will
     return appropriate string output. Content of the string output is
     in line with the calling method's expectations.
 
     :param object monkeypatch: pytest provided fixture for mocking.
     """
+
     def shell_bool_wrapper(object, cmd, env=None, cwd=None, timeout=None, root=False):
         """Actual monkeypatch implementation of the shell_bool method call.
 
         :param object object: placeholder object representing ADBDevice
         :param str cmd: command to be executed
         :param env: contains the environment variable
         :type env: dict or None
         :param cwd: The directory from which to execute.
@@ -166,16 +168,17 @@ def redirect_stdout_and_assert():
 
     This is useful to assert on methods that do not return
     a value, such as most ADBDevice methods.
 
     The original stdout pipe is preserved throughout the process.
 
     :returns: _wrapper method
     """
+
     def _wrapper(func, **kwargs):
         """Implements the stdout sleight-of-hand.
 
         After preserving the original sys.stdout, it is switched
         to use cStringIO.StringIO.
 
         Method with no return value is called, and the stdout
         pipe is switched back to the original sys.stdout.
@@ -188,9 +191,10 @@ def redirect_stdout_and_assert():
         :param dict kwargs: dictionary of function parameters
         """
         original_stdout = sys.stdout
         sys.stdout = testing_stdout = StringIO()
         expected_text = kwargs.pop('text')
         func(**kwargs)
         sys.stdout = original_stdout
         assert expected_text in testing_stdout.getvalue().rstrip()
+
     return _wrapper
--- a/testing/mozbase/mozdevice/tests/manifest.ini
+++ b/testing/mozbase/mozdevice/tests/manifest.ini
@@ -1,7 +1,6 @@
 [DEFAULT]
 subsuite = mozbase
-skip-if = python == 3
 [test_socket_connection.py]
 [test_is_app_installed.py]
 [test_chown.py]
 [test_escape_command_line.py]