Change in vdsm[master]: compat: mock CPopen for Python 3 testing
nsoffer at redhat.com
nsoffer at redhat.com
Tue Mar 29 16:09:23 UTC 2016
Nir Soffer has posted comments on this change.
Change subject: compat: mock CPopen for Python 3 testing
......................................................................
Patch Set 1:
(7 comments)
https://gerrit.ovirt.org/#/c/55379/1//COMMIT_MSG
Commit Message:
Line 8:
Line 9: I would like to run Vdsm unit tests in Python 3, but many tests
Line 10: ultimately attempt to import CPopen. The right thing to do is to remove
Line 11: CPopen dependency from the code, but this task is lagging. Until then,
Line 12: this patch drops CPopen dependecy for Python 3 only.
Nice!
Line 13:
Line 14: Change-Id: I3fb1310dc538ea92879ab1097d897fd7c4e2ef96
https://gerrit.ovirt.org/#/c/55379/1/lib/vdsm/commands.py
File lib/vdsm/commands.py:
Line 30: import signal
Line 31: import threading
Line 32: import time
Line 33: from . import cmdutils
Line 34: from .compat import CPopen
Popen
Line 35: from .exception import ActionStopped
Line 36: from .utils import NoIntrPoll, stripNewLines
Line 37: from vdsm import constants
Line 38:
https://gerrit.ovirt.org/#/c/55379/1/lib/vdsm/compat.py
File lib/vdsm/compat.py:
Line 40: json # yep, this is needed twice.
Line 41:
Line 42: import sys
Line 43: if sys.version_info[0] == 2:
Line 44: from cpopen import CPopen
Just do:
from cpopen import CPopen as Popen
Line 45: CPopen # make pyflakes happy
Line 46: else:
Line 47: from subprocess import Popen, PIPE
Line 48:
Line 43: if sys.version_info[0] == 2:
Line 44: from cpopen import CPopen
Line 45: CPopen # make pyflakes happy
Line 46: else:
Line 47: from subprocess import Popen, PIPE
PIPE can be imported from subprocess, we don't need it here.
Line 48:
Line 49: class CPopen(Popen):
Line 50: """This is a mock for cpopen.CPopen which explodes in run-time when
Line 51: initialized with the CPopen-only argunment deathSignal and childUmask.
Line 45: CPopen # make pyflakes happy
Line 46: else:
Line 47: from subprocess import Popen, PIPE
Line 48:
Line 49: class CPopen(Popen):
We don't need this.
Line 50: """This is a mock for cpopen.CPopen which explodes in run-time when
Line 51: initialized with the CPopen-only argunment deathSignal and childUmask.
Line 52: It is intended to allow testing vdsm code on Python 3, and not for
Line 53: runtime usages.
Line 57: stdin=PIPE, stdout=PIPE, stderr=PIPE,
Line 58: restore_sigpipe=False):
Line 59: if deathSignal != 0 or childUmask is not None:
Line 60: raise AssertionError(
Line 61: 'Popen called within deathSignal or childUmask')
This will fail without adding new code when using Python 3.
Line 62: Popen.__init__(self, args,
Line 63: close_fds=close_fds, cwd=cwd, env=env,
Line 64: stdin=stdin, stdout=stdout,
https://gerrit.ovirt.org/#/c/55379/1/lib/vdsm/qemuimg.py
File lib/vdsm/qemuimg.py:
Line 27: from . import exception
Line 28: from . import utils
Line 29: from . import cmdutils
Line 30: from . import commands
Line 31: from .compat import CPopen
Popen
Line 32:
Line 33: _qemuimg = utils.CommandPath("qemu-img",
Line 34: "/usr/bin/qemu-img",) # Fedora, EL6
Line 35:
--
To view, visit https://gerrit.ovirt.org/55379
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: I3fb1310dc538ea92879ab1097d897fd7c4e2ef96
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Dan Kenigsberg <danken at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczewski at gmail.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybronhei at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes
More information about the vdsm-patches
mailing list