Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Errors in "make test" with Ubuntu 16.04 #2

Closed
bruberg opened this issue Jan 7, 2017 · 4 comments
Closed

Errors in "make test" with Ubuntu 16.04 #2

bruberg opened this issue Jan 7, 2017 · 4 comments

Comments

@bruberg
Copy link

bruberg commented Jan 7, 2017

I'm getting a couple of errors during "make test", this is the first:

__________________________________________________________________________________ TestClientRun.test_run __________________________________________________________________________________

self = <tests.test_client.TestClientRun object at 0x7f1f94f49690>, database_mock = <MagicMock name='Database' id='139773620954064'>
memcached_mock = <MagicMock name='set' id='139773619382672'>, requests_mock = <MagicMock name='post' id='139773620294032'>, avt = <amavisvt.client.AmavisVT object at 0x7f1f9506a0d0>

    @mock.patch('amavisvt.client.requests.post')
    @mock.patch('amavisvt.client.memcache.Client.set')
    @mock.patch('amavisvt.client.Database')
    def test_run(self, database_mock, memcached_mock, requests_mock, avt):
        txt = os.path.join(os.path.dirname(__file__), 'samples/textfile.txt')
>       result = avt.run(txt)

tests/test_client.py:372: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
amavisvt/client.py:409: in run
    return self.process(ResourceSet(resources))
amavisvt/client.py:422: in process
    all_resources = list(_iter_resources())
amavisvt/client.py:419: in _iter_resources
    for x in r:
amavisvt/client.py:229: in __iter__
    for x in self._iter_unpacked(self, 10): # todo: make depth configurable
amavisvt/client.py:237: in _iter_unpacked
    if resource.can_unpack:
amavisvt/client.py:222: in can_unpack
    return self.mime_type in (MAIL_MIME_TYPE,) and not self._no_unpack
amavisvt/client.py:211: in mime_type
    self.examine()
amavisvt/client.py:266: in examine
    self._mime_type = identify_buffer(id_buffer)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

buf = 'test\n'

    def filemagic_id_buffer(buf):
        import magic
>       with magic.Magic(flags=magic.MAGIC_MIME_TYPE) as mgc:
E       TypeError: __init__() got an unexpected keyword argument 'flags'

amavisvt/client.py:52: TypeError

There are more errors (all tests under tests/test_client.py::TestClientRun, and a few more including tests/test_resource.py::TestResourceSet::test_to_addresses and tests/test_unpack.py::TestUnpack::test_empty_file) and they all seem to originate from the same issue:

TypeError: __init__() got an unexpected keyword argument 'flags'

The libmagic version is 5.25. Let me know if I can provide more info.

@ercpe
Copy link
Owner

ercpe commented Jan 7, 2017

How did you install the dependencies of amavisvt? Via pip or via apt?
Unfortunately, there are multiple python libraries which provide bindings to libmagic. amavisvt supports filemagic (https://pypi.python.org/pypi/filemagic) and python-magic (https://github.com/ahupp/python-magic).

Could you please tell me which one (and which version) do you have installed?

@bruberg
Copy link
Author

bruberg commented Jan 7, 2017

All dependencies are installed with apt. These are the ones I have installed for amavisvt:

python-levenshtein : 0.12.0-2build1
python-magic : 1:5.25-2ubuntu1
python-memcache : 1.57-1
python-mock : 1.3.0-2.1ubuntu1
python-pytest : 2.8.7-4
python-requests : 2.9.1-3
python-setproctitle : 1.1.8-1build2

Also, for reference:
libmagic1:amd64 : 1:5.25-2ubuntu1

I can't seem to find python-filemagic available for Ubuntu/Debian.

@ercpe
Copy link
Owner

ercpe commented Jan 7, 2017

The package python-magic in Ubuntu doesn't seem to be the package python-magic on pypi (http://packages.ubuntu.com/xenial/python-magic vs. https://pypi.python.org/pypi/python-magic).

Could you please try to remove the package python-magic via apt and install it from pypi?

@bruberg
Copy link
Author

bruberg commented Jan 7, 2017

That seems correct, the python-magic package provided by Ubuntu seems to be a part of the libmagic1 software. It seems to have at least some of the same functions, though.

Anyway, installing python-magic with pypi made all tests pass. This will work fine, even though I would prefer using packages. Thanks for the support!

@ercpe ercpe closed this as completed Jan 8, 2017
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