h2non/filetype.py

Test failure

dotlambda opened this issue · 6 comments

After updating tp 1.0.12, 3 tests fail:

...E...E...E........
======================================================================
ERROR: test_guess_memoryview (tests.test_filetype.TestFileType)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/filetype-1.0.12/tests/test_filetype.py", line 35, in test_guess_memoryview
    kind = filetype.guess(buf)
  File "/build/filetype-1.0.12/filetype/filetype.py", line 28, in guess
    return match(obj) if obj else None
  File "/build/filetype-1.0.12/filetype/match.py", line 32, in match
    if matcher.match(buf):
  File "/build/filetype-1.0.12/filetype/types/video.py", line 70, in match
    contains_ebml_element = buf.startswith(b'\x1A\x45\xDF\xA3')
AttributeError: 'list' object has no attribute 'startswith'

======================================================================
ERROR: test_guess_extension_memoryview (tests.test_filetype.TestFileTypeExtension)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/filetype-1.0.12/tests/test_filetype.py", line 60, in test_guess_extension_memoryview
    ext = filetype.guess_extension(buf)
  File "/build/filetype-1.0.12/filetype/filetype.py", line 63, in guess_extension
    kind = guess(obj)
  File "/build/filetype-1.0.12/filetype/filetype.py", line 28, in guess
    return match(obj) if obj else None
  File "/build/filetype-1.0.12/filetype/match.py", line 32, in match
    if matcher.match(buf):
  File "/build/filetype-1.0.12/filetype/types/video.py", line 70, in match
    contains_ebml_element = buf.startswith(b'\x1A\x45\xDF\xA3')
AttributeError: 'list' object has no attribute 'startswith'

======================================================================
ERROR: test_guess_mime_memoryview (tests.test_filetype.TestFileTypeMIME)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/filetype-1.0.12/tests/test_filetype.py", line 84, in test_guess_mime_memoryview
    mime = filetype.guess_mime(buf)
  File "/build/filetype-1.0.12/filetype/filetype.py", line 45, in guess_mime
    kind = guess(obj)
  File "/build/filetype-1.0.12/filetype/filetype.py", line 28, in guess
    return match(obj) if obj else None
  File "/build/filetype-1.0.12/filetype/match.py", line 32, in match
    if matcher.match(buf):
  File "/build/filetype-1.0.12/filetype/types/video.py", line 70, in match
    contains_ebml_element = buf.startswith(b'\x1A\x45\xDF\xA3')
AttributeError: 'list' object has no attribute 'startswith'

----------------------------------------------------------------------
Ran 20 tests in 0.020s

FAILED (errors=3)

Ping.

FWIW, this test failure is preventing me from updating the package in Debian.

I have fixed the test cases and added zst(d) support in #127, waiting for accept :-) @h2non

@ferstar Mixing bug fixes and new features in the same PR is often extra work for the maintainer.

It's likely they would prefer to a separate PR to fix this bug here.

@jcharaoui Well, I known, but the bug fix is very simple, and so does the new zstd type feature.

h2non commented

#127 already merged and shipped to PyPI