Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.18: pytest is failing in four units #55

Open
kloczek opened this issue Apr 9, 2022 · 5 comments
Open

2.1.18: pytest is failing in four units #55

kloczek opened this issue Apr 9, 2022 · 5 comments

Comments

@kloczek
Copy link

kloczek commented Apr 9, 2022

I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-virtualenv-api-2.1.18-6.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-virtualenv-api-2.1.18-6.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra tests.py
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.13, pytest-7.1.1, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/virtualenv-api-2.1.18
collected 10 items

tests.py .....FFFF.                                                                                                                                                  [100%]

================================================================================= FAILURES =================================================================================
________________________________________________________________________ SearchTestCase.test_search ________________________________________________________________________

self = <tests.SearchTestCase testMethod=test_search>

    def test_search(self):
        for pack in all_packages_for_tests:
>           result = self.virtual_env_obj.search(pack)

tests.py:106:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
virtualenvapi/manage.py:307: in search
    results = self._execute_pip(['search', term], log=False)  # Don't want to log searches
virtualenvapi/manage.py:132: in _execute_pip
    return self._execute(exec_args, log=log)
virtualenvapi/manage.py:156: in _execute
    raise e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <virtualenvapi.manage.VirtualEnvironment object at 0x7f54fe45cf10>, args = ['bin/python', '-m', 'pip', '--disable-pip-version-check', 'search', 'pep8'], log = False

    def _execute(self, args, log=True):
        """Executes the given command inside the environment and returns the output."""
        if not self._ready:
            self.open_or_create()
        output = ''
        error = ''
        try:
            proc = subprocess.Popen(args, cwd=self.path, env=self.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            output, error = proc.communicate()
            returncode = proc.returncode
            if returncode:
>               raise subprocess.CalledProcessError(returncode, proc, (output, error))
E               subprocess.CalledProcessError: Command '<subprocess.Popen object at 0x7f54fe45cb50>' returned non-zero exit status 1.

virtualenvapi/manage.py:145: CalledProcessError
_____________________________________________________________________ SearchTestCase.test_search_names _____________________________________________________________________

self = <tests.SearchTestCase testMethod=test_search_names>

    def test_search_names(self):
        for pack in all_packages_for_tests:
>           result = self.virtual_env_obj.search_names(pack)

tests.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
virtualenvapi/manage.py:323: in search_names
    return list(self.search(term).keys())
virtualenvapi/manage.py:307: in search
    results = self._execute_pip(['search', term], log=False)  # Don't want to log searches
virtualenvapi/manage.py:132: in _execute_pip
    return self._execute(exec_args, log=log)
virtualenvapi/manage.py:156: in _execute
    raise e
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <virtualenvapi.manage.VirtualEnvironment object at 0x7f54fe477790>, args = ['bin/python', '-m', 'pip', '--disable-pip-version-check', 'search', 'pep8'], log = False

    def _execute(self, args, log=True):
        """Executes the given command inside the environment and returns the output."""
        if not self._ready:
            self.open_or_create()
        output = ''
        error = ''
        try:
            proc = subprocess.Popen(args, cwd=self.path, env=self.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
            output, error = proc.communicate()
            returncode = proc.returncode
            if returncode:
>               raise subprocess.CalledProcessError(returncode, proc, (output, error))
E               subprocess.CalledProcessError: Command '<subprocess.Popen object at 0x7f54fe477820>' returned non-zero exit status 1.

virtualenvapi/manage.py:145: CalledProcessError
________________________________________________________________ PythonArgumentTestCase.test_python_version ________________________________________________________________

self = <tests.PythonArgumentTestCase testMethod=test_python_version>

    def setUp(self):
        self.env_path = tempfile.mkdtemp()
        self.python = which('python')
>       self.assertIsNotNone(self.python)
E       AssertionError: unexpectedly None

tests.py:127: AssertionError
___________________________________________________________ SystemSitePackagesTest.test_no_system_site_packages ____________________________________________________________

self = <tests.SystemSitePackagesTest testMethod=test_no_system_site_packages>

    def test_no_system_site_packages(self):
        """
        test that creating a venv with system_site_packages=False
        results in a venv that contains the no-global-site-packages
        file

        """
        venv = VirtualEnvironment(self.dir)
        venv._create()
        expected = os.path.join(venv.path, self.no_global)
>       self.assertTrue(
            os.path.exists(expected)
        )
E       AssertionError: False is not true

tests.py:187: AssertionError
========================================================================= short test summary info ==========================================================================
FAILED tests.py::SearchTestCase::test_search - subprocess.CalledProcessError: Command '<subprocess.Popen object at 0x7f54fe45cb50>' returned non-zero exit status 1.
FAILED tests.py::SearchTestCase::test_search_names - subprocess.CalledProcessError: Command '<subprocess.Popen object at 0x7f54fe477820>' returned non-zero exit status 1.
FAILED tests.py::PythonArgumentTestCase::test_python_version - AssertionError: unexpectedly None
FAILED tests.py::SystemSitePackagesTest::test_no_system_site_packages - AssertionError: False is not true
======================================================================= 4 failed, 6 passed in 57.93s =======================================================================
@musicinmybrain
Copy link

I was looking at picking up the orphaned python-virtualenv-api package in Fedora Linux, and I see similar but not identical failures.

$ fedpkg --release rawhide mockbuild --with tests --enable-network
[…]
+ /usr/bin/python3 -m unittest -v tests.py
test_install (tests.InstalledTestCase.test_install) ... ok
test_install_requirements (tests.InstalledTestCase.test_install_requirements)
test installing Python packages from a pip requirements file ... ok
test_installed (tests.InstalledTestCase.test_installed) ... ok
test_uninstall (tests.InstalledTestCase.test_uninstall) ... ok
test_wheel (tests.InstalledTestCase.test_wheel) ... ok
test_python_version (tests.PythonArgumentTestCase.test_python_version) ... FAIL
test_search (tests.SearchTestCase.test_search) ... ERROR
test_search_names (tests.SearchTestCase.test_search_names) ... ERROR
test_no_system_site_packages (tests.SystemSitePackagesTest.test_no_system_site_packages)
test that creating a venv with system_site_packages=False ... FAIL
test_system_site_packages (tests.SystemSitePackagesTest.test_system_site_packages)
test that creating a venv with system_site_packages=True ... ok

======================================================================
ERROR: test_search (tests.SearchTestCase.test_search)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/tests.py", line 106, in test_search
    result = self.virtual_env_obj.search(pack)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 307, in search
    results = self._execute_pip(['search', term], log=False)  # Don't want to log searches
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 132, in _execute_pip
    return self._execute(exec_args, log=log)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 156, in _execute
    raise e
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 145, in _execute
    raise subprocess.CalledProcessError(returncode, proc, (output, error))
subprocess.CalledProcessError: Command '<Popen: returncode: 1 args: ['bin/python', '-m', 'pip', '--disable-pip-versi...>' returned non-zero exit status 1.

======================================================================
ERROR: test_search_names (tests.SearchTestCase.test_search_names)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/tests.py", line 114, in test_search_names
    result = self.virtual_env_obj.search_names(pack)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 323, in search_names
    return list(self.search(term).keys())
                ^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 307, in search
    results = self._execute_pip(['search', term], log=False)  # Don't want to log searches
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 132, in _execute_pip
    return self._execute(exec_args, log=log)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 156, in _execute
    raise e
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/virtualenvapi/manage.py", line 145, in _execute
    raise subprocess.CalledProcessError(returncode, proc, (output, error))
subprocess.CalledProcessError: Command '<Popen: returncode: 1 args: ['bin/python', '-m', 'pip', '--disable-pip-versi...>' returned non-zero exit status 1.

======================================================================
FAIL: test_python_version (tests.PythonArgumentTestCase.test_python_version)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/tests.py", line 127, in setUp
    self.assertIsNotNone(self.python)
AssertionError: unexpectedly None

======================================================================
FAIL: test_no_system_site_packages (tests.SystemSitePackagesTest.test_no_system_site_packages)
test that creating a venv with system_site_packages=False
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/virtualenv-api-2.1.18/tests.py", line 187, in test_no_system_site_packages
    self.assertTrue(
AssertionError: False is not true

----------------------------------------------------------------------
Ran 10 tests in 20.967s

FAILED (failures=2, errors=2)

It doesn’t seem like these are specific to the RPM build environment; I see the same thing if I install the python3-virtualenv-api package, copy tests.py to an empty directory, and run python3 -m unittest -v tests.py.

@musicinmybrain
Copy link

It appears that test_no_system_site_packages (tests.SystemSitePackagesTest.test_no_system_site_packages) would be fixed by #52.

@musicinmybrain
Copy link

It appears that test_search and test_search_names would be fixed by #48.

@musicinmybrain
Copy link

For the final failure, test_python_version, I have submitted #56.

@musicinmybrain
Copy link

@sjkingo, I know that this package is not very actively maintained, but would it be possible to review some of the open PR’s and make a bugfix release? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants