Tests failing
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 304
- PR merge metrics
- No merged PRs in 30d
Description
It seems that the current output has parenthesis around s of pages.
This is building the module in Mageia cauldron. libmagic is at 5.45.
+ /usr/bin/pytest
============================= test session starts ==============================
platform linux -- Python 3.12.8, pytest-8.3.4, pluggy-1.5.0
rootdir: /home/pterjan/rpmbuild/BUILD/python-magic-0.4.27-build/python-magic-0.4.27
collected 20 items
test/libmagic_test.py FFF [ 15%]
test/python_magic_test.py F.............ss. [100%]
=================================== FAILURES ===================================
____________________ MagicTestCase.test_detect_from_content ____________________
self = <test.libmagic_test.MagicTestCase testMethod=test_detect_from_content>
def test_detect_from_content(self):
# differ from upstream by opening file in binary mode,
# this avoids hitting a bug in python3+libfile bindings
# see https://github.com/ahupp/python-magic/issues/152
# for a similar issue
with open(self.filename, 'rb') as fobj:
result = magic.detect_from_content(fobj.read(4096))
> self.assert_result(result)
test/libmagic_test.py:46:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/libmagic_test.py:23: in assert_result
self.assertIn(result.name, self.expected_name)
E AssertionError: 'PDF document, version 1.2, 2 page(s)' not found in ('PDF document, version 1.2', 'PDF document, version 1.2, 2 pages')
___________________ MagicTestCase.test_detect_from_filename ____________________
self = <test.libmagic_test.MagicTestCase testMethod=test_detect_from_filename>
def test_detect_from_filename(self):
result = magic.detect_from_filename(self.filename)
> self.assert_result(result)
test/libmagic_test.py:27:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/libmagic_test.py:23: in assert_result
self.assertIn(result.name, self.expected_name)
E AssertionError: 'PDF document, version 1.2, 2 page(s)' not found in ('PDF document, version 1.2', 'PDF document, version 1.2, 2 pages')
_____________________ MagicTestCase.test_detect_from_fobj ______________________
self = <test.libmagic_test.MagicTestCase testMethod=test_detect_from_fobj>
def test_detect_from_fobj(self):
if SKIP_FROM_DESCRIPTOR:
self.skipTest("magic_descriptor is broken in this version of libmagic")
with open(self.filename) as fobj:
result = magic.detect_from_fobj(fobj)
> self.assert_result(result)
test/libmagic_test.py:37:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/libmagic_test.py:23: in assert_result
self.assertIn(result.name, self.expected_name)
E AssertionError: 'PDF document, version 1.2, 2 page(s)' not found in ('PDF document, version 1.2', 'PDF document, version 1.2, 2 pages')
_________________________ MagicTest.test_descriptions __________________________
self = <test.python_magic_test.MagicTest testMethod=test_descriptions>
def test_descriptions(self):
m = magic.Magic()
os.environ['TZ'] = 'UTC' # To get last modified date of test.gz in UTC
try:
> self.assert_values(m, {
'magic._pyc_': 'python 2.4 byte-compiled',
'test.pdf': ('PDF document, version 1.2',
'PDF document, version 1.2, 2 pages'),
'test.gz':
('gzip compressed data, was "test", from Unix, last '
'modified: Sun Jun 29 01:32:52 2008',
'gzip compressed data, was "test", last modified'
': Sun Jun 29 01:32:52 2008, from Unix',
'gzip compressed data, was "test", last modified'
': Sun Jun 29 01:32:52 2008, from Unix, original size 15',
'gzip compressed data, was "test", '
'last modified: Sun Jun 29 01:32:52 2008, '
'from Unix, original size modulo 2^32 15',
'gzip compressed data, was "test", last modified'
': Sun Jun 29 01:32:52 2008, from Unix, truncated'
),
'text.txt': 'ASCII text',
'test.snappy.parquet': ('Apache Parquet', 'Par archive data'),
}, buf_equals_file=False)
test/python_magic_test.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test/python_magic_test.py:53: in assert_values
self.assertIn(value, expected_value)
E AssertionError: 'PDF document, version 1.2, 2 page(s)' not found in ('PDF document, version 1.2', 'PDF document, version 1.2, 2 pages')
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test/libmagic_test.py and test/python_magic_test.py, especially the expected PDF descriptions and assert_result/assert_values calls. Run pytest with libmagic 5.45 to reproduce the reported wording differences. Done means the tests accept the supported output variants and the full test suite passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100