Skip to content
This repository has been archived by the owner on Nov 25, 2023. It is now read-only.

1.0.0: pytest is failing #17

Open
kloczek opened this issue Dec 26, 2021 · 2 comments
Open

1.0.0: pytest is failing #17

kloczek opened this issue Dec 26, 2021 · 2 comments

Comments

@kloczek
Copy link

kloczek commented Dec 26, 2021

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
  • install .whl file in </install/prefix>
  • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

On top of the 1.0.0 I'mm adding patch:

--- a/linecache2/tests/test_linecache.py        2015-03-06 01:33:05.000000000 +0000
+++ b/linecache2/tests/test_linecache.py        2021-12-26 06:31:03.915721698 +0000
@@ -1,7 +1,7 @@
 """ Tests for the linecache module """

 import linecache2 as linecache
-import unittest2 as unittest
+import unittest
 import os.path
 import tempfile

Which allows use standart unitetst instead unitest2.

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-linecache2-1.0.0-32.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-linecache2-1.0.0-32.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra --deselect tests/test_linecache.py::LineCacheTests::test_lazycache_already_cached --deselect tests/test_linecache.py::LineCacheTests::test_lazycache_smoke
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
Using --randomly-seed=2491370604
rootdir: /home/tkloczko/rpmbuild/BUILD/linecache2-1.0.0
plugins: freezegun-0.4.2, mock-3.6.1, randomly-3.10.3, timeout-2.0.2, flaky-3.7.0, cov-3.0.0
collected 10 items

linecache2/tests/test_linecache.py ..F..F....                                                                                                                        [100%]

================================================================================= FAILURES =================================================================================
_______________________________________________________________ LineCacheTests.test_lazycache_already_cached _______________________________________________________________

self = <linecache2.tests.test_linecache.LineCacheTests testMethod=test_lazycache_already_cached>

    @unittest.skipIf("__loader__" not in globals(), "Modules not PEP302 by default")
    def test_lazycache_already_cached(self):
        linecache.clearcache()
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        self.assertEqual(
            False,
            linecache.lazycache(NONEXISTENT_FILENAME, globals()))
>       self.assertEqual(4, len(linecache.cache[NONEXISTENT_FILENAME]))
E       KeyError: '/usr/lib64/python3.8/os.py.missing'

linecache2/tests/test_linecache.py:184: KeyError
___________________________________________________________________ LineCacheTests.test_lazycache_smoke ____________________________________________________________________

self = <linecache2.tests.test_linecache.LineCacheTests testMethod=test_lazycache_smoke>

    @unittest.skipIf("__loader__" not in globals(), "Modules not PEP302 by default")
    def test_lazycache_smoke(self):
        lines = linecache.getlines(NONEXISTENT_FILENAME, globals())
        linecache.clearcache()
>       self.assertEqual(
            True, linecache.lazycache(NONEXISTENT_FILENAME, globals()))
E       AssertionError: True != False

linecache2/tests/test_linecache.py:152: AssertionError
============================================================================= warnings summary =============================================================================
../../../../../usr/lib/python3.8/site-packages/pytest_freezegun.py:17: 20 warnings
  /usr/lib/python3.8/site-packages/pytest_freezegun.py:17: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    if LooseVersion(pytest.__version__) < LooseVersion('3.6.0'):

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
FAILED linecache2/tests/test_linecache.py::LineCacheTests::test_lazycache_already_cached - KeyError: '/usr/lib64/python3.8/os.py.missing'
FAILED linecache2/tests/test_linecache.py::LineCacheTests::test_lazycache_smoke - AssertionError: True != False
================================================================= 2 failed, 8 passed, 20 warnings in 0.28s =================================================================
@jelmer
Copy link
Member

jelmer commented Dec 27, 2021

Any particular reason you're still trying to package linecache2? It's meant to just be a backport of the linecache package, which is bundled with modern versions of Python.

@kloczek
Copy link
Author

kloczek commented Dec 27, 2021

Just checked my spec files and looks like linecache2 is used by traceback2 which seems still is used by samba. However I'm not 100% sure is it still in use as I've added that build dependency quite long time ago (and you may be right about not straight suggestion to check is that still necessary to maintain package with that module :) ).

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

No branches or pull requests

2 participants