Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#260 closed defect (fixed)

"import magic" should be tested more thoroughly

Reported by: bthiell Owned by: bthiell
Priority: minor Milestone:
Component: *general* Version:
Keywords: Cc:

Description

In bibdocfile, elmsubmit_filename_generator and configure-tests, we test the import of the module magic. These tests are not sufficient as other Python modules are named magic but do not offer all the variables or functions needed in the code.

So we also need to test that all variables and functions used are present in the imported module, e.g.:

try:
    import magic
    if not hasattr(magic, 'open'):
        raise ImportError
    CFG_HAS_MAGIC = True
except ImportError:
    CFG_HAS_MAGIC = False

Change History (6)

comment:1 Changed 4 years ago by bthiell

  • Status changed from new to assigned

comment:2 Changed 4 years ago by bthiell

  • Status changed from assigned to in_merge

Commit 9208ef210a77c93c1b432321940aecae59454194 fixes the issue.

Ideally Invenio should also support the package being the 1st hit on Google when searching for "python-magic": http://pypi.python.org/pypi/python-magic/0.1

comment:3 Changed 4 years ago by Benoit Thiell <bthiell@…>

  • Resolution set to fixed
  • Status changed from in_merge to closed

In [b68827cf1aa6a1dbfb1613ad14ea87f6de012a00]:

kwalitee: better check of python-magic import

  • Check that the python-magic package is the one supported by Invenio. (closes #260)

comment:4 Changed 4 years ago by simko

Committed, thanks.

WRT commit log messages, please don't forget to add things like
closes #260 or addresses #260 so that the auto-closure works, see
https://twiki.cern.ch/twiki/bin/view/CDS/GitWorkflow#R1_Remarks_on_Git_log_messages.
(Otherwise I'm adding them, but it is nicer/quicker if you do.)

WRT personal branch names, they may occasionally appear in the repo
history, if things are merged and not cherry-picked. So, generally
speaking, please use something more descriptive than the sole Trac
ticket number. This will make the repo to be nicely usable in the
offline mode: one does not always have online access to Trac, and the
ticket number appears in the commit log message anyway.

comment:5 follow-up: Changed 4 years ago by Benoit Thiell <bthiell@…>

In [6b1b68977673b9a65f4eacfd21cd2adb7ad9680c]:

kwalitee: close mkstemp temporary files

  • Properly close temporary files open by tempfile.mkstemp. (closes #260)

comment:6 in reply to: ↑ 5 Changed 4 years ago by simko

Replying to Benoit Thiell <bthiell@…>:

  • Properly close temporary files open by tempfile.mkstemp. (closes #260)

Wrong ticket number, should have been #262. (spotted after merge)

Last edited 4 years ago by simko (previous) (diff)
Note: See TracTickets for help on using tickets.