Skip to content

Tests failing #340

Description

@papoteur-mga

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')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions