[Bug 1481875] Review Request: python-pytest-virtualenv - Virtualenv fixture for py.test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



https://bugzilla.redhat.com/show_bug.cgi?id=1481875



--- Comment #4 from Robert-André Mauchin <zebob.m@xxxxxxxxx> ---
pytest-shutil is done.

First I had to add the following BR for the tests:

BuildRequires:  python2-pytest-fixture-config python3-pytest-fixture-config
BuildRequires:  python2-path python3-path
BuildRequires:  python2-execnet python3-execnet


Then one test fails:

============================= test session starts
==============================
platform linux2 -- Python 2.7.13, pytest-3.2.1, py-1.4.34, pluggy-0.4.0
rootdir: /builddir/build/BUILD/pytest-virtualenv-1.2.11, inifile: setup.cfg
plugins: virtualenv-1.2.11, shutil-1.2.11
collected 16 items
tests/integration/test_tmpvirtualenv.py F
tests/unit/test_package_entry.py .............
tests/unit/test_venv.py ..
- generated xml file: /builddir/build/BUILD/pytest-virtualenv-1.2.11/junit.xml
-
=================================== FAILURES
===================================
___________________________ test_installed_packages
____________________________
    def test_installed_packages():
>       with venv.VirtualEnv() as v:
tests/integration/test_tmpvirtualenv.py:9: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pytest_virtualenv.py:139: in __init__
    self.run(cmd)
pytest_virtualenv.py:147: in run
    return super(VirtualEnv, self).run(args, **kwargs)
/usr/lib/python2.7/site-packages/pytest_shutil/workspace.py:116: in run
    p = subprocess.Popen(cmd, shell=shell, **kwargs)
/usr/lib64/python2.7/subprocess.py:390: in __init__
    errread, errwrite)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <subprocess.Popen object at 0x7f64c2f33150>
args = ['virtualenv', '-p', '/usr/bin/python2.7', '/tmp/tmpf634XI/.env']
executable = 'virtualenv', preexec_fn = None, close_fds = False, cwd = None
env = {'BASH_ENV': '/usr/share/lmod/lmod/init/bash', 'BASH_FUNC_ml%%': '() { 
eval $($LMOD_DIR/ml_cmd "$@")\n}', 'BASH_FUNC_module%%': '() {  eval
$($LMOD_CMD bash "$@") && eval $(${LMOD_SETTARG_CMD:-:} -s sh)\n}',
'CONFIG_SITE': 'NONE', ...}
universal_newlines = False, startupinfo = None, creationflags = 0, shell =
False
to_close = set([]), p2cread = None, p2cwrite = None, c2pread = None
c2pwrite = None, errread = None, errwrite = None
    def _execute_child(self, args, executable, preexec_fn, close_fds,
                       cwd, env, universal_newlines,
                       startupinfo, creationflags, shell, to_close,
                       p2cread, p2cwrite,
                       c2pread, c2pwrite,
                       errread, errwrite):
        """Execute program (POSIX version)"""

        if isinstance(args, types.StringTypes):
            args = [args]
        else:
            args = list(args)

        if shell:
            args = ["/bin/sh", "-c"] + args
            if executable:
                args[0] = executable

        if executable is None:
            executable = args[0]

        def _close_in_parent(fd):
            os.close(fd)
            to_close.remove(fd)

        # For transferring possible exec failure from child to parent
        # The first char specifies the exception type: 0 means
        # OSError, 1 means some other error.
        errpipe_read, errpipe_write = self.pipe_cloexec()
        try:
            try:
                gc_was_enabled = gc.isenabled()
                # Disable gc to avoid bug where gc -> file_dealloc ->
                # write to stderr -> hang.  http://bugs.python.org/issue1336
                gc.disable()
                try:
                    self.pid = os.fork()
                except:
                    if gc_was_enabled:
                        gc.enable()
                    raise
                self._child_created = True
                if self.pid == 0:
                    # Child
                    try:
                        # Close parent's pipe ends
                        if p2cwrite is not None:
                            os.close(p2cwrite)
                        if c2pread is not None:
                            os.close(c2pread)
                        if errread is not None:
                            os.close(errread)
                        os.close(errpipe_read)

                        # When duping fds, if there arises a situation
                        # where one of the fds is either 0, 1 or 2, it
                        # is possible that it is overwritten (#12607).
                        if c2pwrite == 0:
                            c2pwrite = os.dup(c2pwrite)
                        if errwrite == 0 or errwrite == 1:
                            errwrite = os.dup(errwrite)

                        # Dup fds for child
                        def _dup2(a, b):
                            # dup2() removes the CLOEXEC flag but
                            # we must do it ourselves if dup2()
                            # would be a no-op (issue #10806).
                            if a == b:
                                self._set_cloexec_flag(a, False)
                            elif a is not None:
                                os.dup2(a, b)
                        _dup2(p2cread, 0)
                        _dup2(c2pwrite, 1)
                        _dup2(errwrite, 2)

                        # Close pipe fds.  Make sure we don't close the
                        # same fd more than once, or standard fds.
                        closed = { None }
                        for fd in [p2cread, c2pwrite, errwrite]:
                            if fd not in closed and fd > 2:
                                os.close(fd)
                                closed.add(fd)

                        if cwd is not None:
                            os.chdir(cwd)

                        if preexec_fn:
                            preexec_fn()

                        # Close all other fds, if asked for - after
                        # preexec_fn(), which may open FDs.
                        if close_fds:
                            self._close_fds(but=errpipe_write)

                        if env is None:
                            os.execvp(executable, args)
                        else:
                            os.execvpe(executable, args, env)

                    except:
                        exc_type, exc_value, tb = sys.exc_info()
                        # Save the traceback and attach it to the exception
object
                        exc_lines = traceback.format_exception(exc_type,
                                                               exc_value,
                                                               tb)
                        exc_value.child_traceback = ''.join(exc_lines)
                        os.write(errpipe_write, pickle.dumps(exc_value))

                    # This exitcode won't be reported to applications, so it
                    # really doesn't matter what we return.
                    os._exit(255)

                # Parent
                if gc_was_enabled:
                    gc.enable()
            finally:
                # be sure the FD is closed no matter what
                os.close(errpipe_write)

            # Wait for exec to fail or succeed; possibly raising exception
            data = _eintr_retry_call(os.read, errpipe_read, 1048576)
            pickle_bits = []
            while data:
                pickle_bits.append(data)
                data = _eintr_retry_call(os.read, errpipe_read, 1048576)
            data = "".join(pickle_bits)
        finally:
            if p2cread is not None and p2cwrite is not None:
                _close_in_parent(p2cread)
            if c2pwrite is not None and c2pread is not None:
                _close_in_parent(c2pwrite)
            if errwrite is not None and errread is not None:
                _close_in_parent(errwrite)

            # be sure the FD is closed no matter what
            os.close(errpipe_read)

        if data != "":
            try:
                _eintr_retry_call(os.waitpid, self.pid, 0)
            except OSError as e:
                if e.errno != errno.ECHILD:
                    raise
            child_exception = pickle.loads(data)
>           raise child_exception
E           OSError: [Errno 2] No such file or directory
/usr/lib64/python2.7/subprocess.py:1024: OSError
----------------------------- Captured stderr call
-----------------------------
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace 
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace
=======================================================
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace pytest_shutil created
workspace /tmp/tmpf634XI
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace This workspace will
delete itself on teardown
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace
=======================================================
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace 
2017-08-29 16:35:47,080 DEBUG pytest_shutil.workspace run: ['virtualenv', '-p',
'/usr/bin/python2.7', '/tmp/tmpf634XI/.env']
=============================== warnings summary
===============================
None
  Module already imported so can not be re-written: common_setup
  Module already imported so can not be re-written: common_setup
-- Docs: http://doc.pytest.org/en/latest/warnings.html
=============== 1 failed, 15 passed, 2 warnings in 0.08 seconds
================


Didn't you encounter the same issue?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are always notified about changes to this product and component
_______________________________________________
package-review mailing list -- package-review@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to package-review-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite Conditions]     [KDE Users]

  Powered by Linux