Bug 1481875 - Review Request: python-pytest-virtualenv - Virtualenv fixture for py.test
Summary: Review Request: python-pytest-virtualenv - Virtualenv fixture for py.test
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: Package Review
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Robert-André Mauchin 🐧
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 1481876
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-15 23:04 UTC by Kevin Fenzi
Modified: 2017-09-18 16:34 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-09-18 16:34:04 UTC
Type: ---
Embargoed:
eclipseo: fedora-review+


Attachments (Terms of Use)

Description Kevin Fenzi 2017-08-15 23:04:53 UTC
Spec URL: http://www.scrye.com/~kevin/fedora/review/python-pytest-virtualenv/python-pytest-virtualenv.spec
SRPM URL: http://www.scrye.com/~kevin/fedora/review/python-pytest-virtualenv/python-pytest-virtualenv-1.2.11-1.fc27.src.rpm
Description: 
Create a Python virtual environment in your test that cleans up on teardown.
The fixture has utility methods to install packages and list what's installed.

Fedora Account System Username: kevin

Needed for python-setuptools tests.

Comment 1 Robert-André Mauchin 🐧 2017-08-18 13:59:51 UTC
I've got an error while running the test:

+ /usr/bin/python2 setup.py test
running test
Searching for pytest-shutil
Reading https://pypi.python.org/simple/pytest-shutil/
Download error on https://pypi.python.org/simple/pytest-shutil/: [Errno -2] Name or service not known -- Some packages may not be found!
Scanning index of all packages (this may take a while)
Couldn't find index page for 'pytest-shutil' (maybe misspelled?)

Thus mock fails.

Comment 2 Scott Talbert 2017-08-18 14:09:12 UTC
@Robert-André, I believe this needs pytest-shutil, for which Kevin has another review request open.  That's why I stepped back for now.  I added it as a blocker.

Comment 3 Kevin Fenzi 2017-08-19 18:47:49 UTC
Sorry about that. I meant to set dependencies here, but obviously failed to. 

Yes, this does need pytest-shutil first.

Comment 4 Robert-André Mauchin 🐧 2017-08-29 14:43:10 UTC
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?

Comment 5 Kevin Fenzi 2017-09-16 19:41:58 UTC
Ah, sorry about that. Thats due to missing python{23}-virtualenv BuildRequires.

Spec URL: http://www.scrye.com/~kevin/fedora/review/python-pytest-virtualenv/python-pytest-virtualenv.spec
SRPM URL: http://www.scrye.com/~kevin/fedora/review/python-pytest-virtualenv/python-pytest-virtualenv-1.2.11-2.fc28.src.rpm

Everything should hopefully be fixed now and this should be ready to review.

Comment 6 Robert-André Mauchin 🐧 2017-09-17 07:33:31 UTC
Everything is okay but you should query upstream for a license file.


Package Review
==============

Legend:
[x] = Pass, [!] = Fail, [-] = Not applicable, [?] = Not evaluated
[ ] = Manual review needed



===== MUST items =====

Generic:
[x]: Package is licensed with an open-source compatible license and meets
     other legal requirements as defined in the legal section of Packaging
     Guidelines.
[-]: If (and only if) the source package includes the text of the
     license(s) in its own file, then that file, containing the text of the
     license(s) for the package is included in %license.
[x]: License field in the package spec file matches the actual license.
     Note: Checking patched sources after %prep for licenses. Licenses
     found: "Unknown or generated". 18 files have unknown license. Detailed
     output of licensecheck in /home/bob/packaging/review/python-pytest-
     virtualenv/review-python-pytest-virtualenv/licensecheck.txt
[x]: License file installed when any subpackage combination is installed.
[x]: Package does not own files or directories owned by other packages.
     Note: Dirs in package are owned also by: /usr/lib/python3.6/site-
     packages/__pycache__(python3-cycler, python3-sh, python3-libs)
[x]: Package contains no bundled libraries without FPC exception.
[x]: Changelog in prescribed format.
[x]: Sources contain only permissible code or content.
[-]: Package contains desktop file if it is a GUI application.
[-]: Development files must be in a -devel package
[x]: Package uses nothing in %doc for runtime.
[x]: Package consistently uses macros (instead of hard-coded directory
     names).
[x]: Package is named according to the Package Naming Guidelines.
[x]: Package does not generate any conflict.
[x]: Package obeys FHS, except libexecdir and /usr/target.
[-]: If the package is a rename of another package, proper Obsoletes and
     Provides are present.
[x]: Requires correct, justified where necessary.
[x]: Spec file is legible and written in American English.
[-]: Package contains systemd file(s) if in need.
[x]: Package is not known to require an ExcludeArch tag.
[-]: Large documentation must go in a -doc subpackage. Large could be size
     (~1MB) or number of files.
     Note: Documentation size is 20480 bytes in 4 files.
[x]: Package complies to the Packaging Guidelines
[x]: Package successfully compiles and builds into binary rpms on at least
     one supported primary architecture.
[x]: Package installs properly.
[x]: Rpmlint is run on all rpms the build produces.
     Note: There are rpmlint messages (see attachment).
[x]: Package requires other packages for directories it uses.
[x]: Package must own all directories that it creates.
[x]: All build dependencies are listed in BuildRequires, except for any
     that are listed in the exceptions section of Packaging Guidelines.
[x]: Package uses either %{buildroot} or $RPM_BUILD_ROOT
[x]: Package does not run rm -rf %{buildroot} (or $RPM_BUILD_ROOT) at the
     beginning of %install.
[x]: Macros in Summary, %description expandable at SRPM build time.
[x]: Dist tag is present.
[x]: Package does not contain duplicates in %files.
[x]: Permissions on files are set properly.
[x]: Package use %makeinstall only when make install DESTDIR=... doesn't
     work.
[x]: Package is named using only allowed ASCII characters.
[x]: Package does not use a name that already exists.
[x]: Package is not relocatable.
[x]: Sources used to build the package match the upstream source, as
     provided in the spec URL.
[x]: Spec file name must match the spec package %{name}, in the format
     %{name}.spec.
[x]: File names are valid UTF-8.
[x]: Packages must not store files under /srv, /opt or /usr/local

Python:
[x]: Python eggs must not download any dependencies during the build
     process.
[x]: A package which is used by another package via an egg interface should
     provide egg info.
[x]: Package meets the Packaging Guidelines::Python
[x]: Package contains BR: python2-devel or python3-devel
[x]: Binary eggs must be removed in %prep

===== SHOULD items =====

Generic:
[!]: If the source package does not include license text(s) as a separate
     file from upstream, the packager SHOULD query upstream to include it.
[x]: Final provides and requires are sane (see attachments).
[x]: Fully versioned dependency in subpackages if applicable.
     Note: No Requires: %{name}%{?_isa} = %{version}-%{release} in python2
     -pytest-virtualenv , python3-pytest-virtualenv
[?]: Package functions as described.
[x]: Latest version is packaged.
[x]: Package does not include license text files separate from upstream.
[-]: Description and summary sections in the package spec file contains
     translations for supported Non-English languages, if available.
[x]: Package should compile and build into binary rpms on all supported
     architectures.
[x]: %check is present and all tests pass.
[x]: Packages should try to preserve timestamps of original installed
     files.
[x]: Reviewer should test that the package builds in mock.
[x]: Buildroot is not present
[x]: Package has no %clean section with rm -rf %{buildroot} (or
     $RPM_BUILD_ROOT)
[x]: No file requires outside of /etc, /bin, /sbin, /usr/bin, /usr/sbin.
[x]: Packager, Vendor, PreReq, Copyright tags should not be in spec file
[x]: Sources can be downloaded from URI in Source: tag
[x]: SourceX is a working URL.
[x]: Spec use %global instead of %define unless justified.

===== EXTRA items =====

Generic:
[x]: Rpmlint is run on all installed packages.
     Note: There are rpmlint messages (see attachment).
[x]: Spec file according to URL is the same as in SRPM.


Rpmlint
-------
Checking: python2-pytest-virtualenv-1.2.11-2.fc28.noarch.rpm
          python3-pytest-virtualenv-1.2.11-2.fc28.noarch.rpm
          python-pytest-virtualenv-1.2.11-2.fc28.src.rpm
python2-pytest-virtualenv.noarch: W: spelling-error Summary(en_US) py -> pt, p, y
python2-pytest-virtualenv.noarch: W: spelling-error %description -l en_US teardown -> tear down, tear-down, downhearted
python3-pytest-virtualenv.noarch: W: spelling-error Summary(en_US) py -> pt, p, y
python3-pytest-virtualenv.noarch: W: spelling-error %description -l en_US teardown -> tear down, tear-down, downhearted
python-pytest-virtualenv.src: W: spelling-error Summary(en_US) py -> pt, p, y
python-pytest-virtualenv.src: W: spelling-error %description -l en_US teardown -> tear down, tear-down, downhearted
3 packages and 0 specfiles checked; 0 errors, 6 warnings.

Comment 7 Gwyn Ciesla 2017-09-18 11:39:04 UTC
(fedrepo-req-admin):  The Pagure repository was created at https://src.fedoraproject.org/rpms/python-pytest-virtualenv

Comment 8 Kevin Fenzi 2017-09-18 16:34:04 UTC
Built in rawhide.


Note You need to log in before you can comment on or make changes to this bug.