ahupp / ahupp/python-magic

0.4.27: pytest is failing

Open
#285 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
304
PR merge metrics
No merged PRs in 30d

Description

I'm packaging 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>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")

Here is pytest output:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-magic-0.4.27-4.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-magic-0.4.27-4.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.8.16, pytest-7.2.2, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/python-magic-0.4.27
collected 20 items

test/libmagic_test.py ...                                                                                                                                                             [ 15%]
test/python_magic_test.py ..F...........ss.                                                                                                                                           [100%]

========================================================================================= FAILURES ==========================================================================================
_________________________________________________________________________________ MagicTest.test_extension __________________________________________________________________________________

self = <test.python_magic_test.MagicTest testMethod=test_extension>

    def test_extension(self):
        try:
            m = magic.Magic(extension=True)
>           self.assert_values(m, {
                # some versions return '' for the extensions of a gz file,
                # including w/ the command line.  Who knows...
                'test.gz': ('gz/tgz/tpz/zabw/svgz', '', '???'),
                'name_use.jpg': 'jpeg/jpg/jpe/jfif',
            })

test/python_magic_test.py:134:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/python_magic_test.py:53: in assert_values
    self.assertIn(value, expected_value)
E   AssertionError: 'gz/tgz/tpz/zabw/svgz/adz/kmy/xcfgz' not found in ('gz/tgz/tpz/zabw/svgz', '', '???')
===================================================================================== warnings summary ======================================================================================
test/libmagic_test.py::MagicTestCase::test_detect_from_content
test/libmagic_test.py::MagicTestCase::test_detect_from_filename
test/libmagic_test.py::MagicTestCase::test_detect_from_fobj
  /home/tkloczko/rpmbuild/BUILD/python-magic-0.4.27/magic/__init__.py:437: PendingDeprecationWarning: Using compatibility mode with libmagic's python binding. See https://github.com/ahupp/python-magic/blob/master/COMPAT.md for details.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
SKIPPED [1] test/python_magic_test.py:143: Magic file doesn't return expected type.
SKIPPED [1] test/python_magic_test.py:153: Magic file doesn't return expected type.
FAILED test/python_magic_test.py::MagicTest::test_extension - AssertionError: 'gz/tgz/tpz/zabw/svgz/adz/kmy/xcfgz' not found in ('gz/tgz/tpz/zabw/svgz', '', '???')
==================================================================== 1 failed, 17 passed, 2 skipped, 3 warnings in 0.14s ====================================================================

Here is list of installed modules in build env

Package         Version
--------------- --------------
attrs           22.2.0
build           0.10.0
distro          1.8.0
exceptiongroup  1.0.0
gpg             1.18.0-unknown
iniconfig       2.0.0
libcomps        0.1.19
packaging       23.0
pip             23.0.1
pluggy          1.0.0
pyproject_hooks 1.0.0
pytest          7.2.2
python-dateutil 2.8.2
rpm             4.17.0
setuptools      65.6.3
six             1.16.0
tomli           2.0.1
wheel           0.38.4

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/python_magic_test.py, especially MagicTest.test_extension and assert_values, then compare the reported extension list with the libmagic version used in the failing environment. Run pytest -m 'not network' to verify the failure and confirm that the extension test passes across the supported behavior without requiring network access.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.