[New-bugs-announce] [issue28276] test_loading.py - false positive result for "def test_find" when find_library() is not functional or the (shared) library does not exist

Michael Felt report at bugs.python.org
Mon Sep 26 07:04:43 EDT 2016


New submission from Michael Felt:

in Lib/ctypes/test/test_loading.py there is the following test

    def test_find(self):
        for name in ("c", "m"):
            lib = find_library(name)
            if lib:
                cdll.LoadLibrary(lib)
                CDLL(lib)


1. on AIX, the test is "broken" because lib is None for both names because:
a1) find_library is basically broken for AIX (needs ldconfig, gcc, and/or other tools not generally available on AIX (production) servers
a2) "m" will always fail because there is no equivalent to libm.so - AIX libm.a only has static members - none are shared.
2. IMHO - the test is misnamed "test_find" - as None is an acceptable answer - which is why it 'appears' to PASS on AIX

As far as library names to look for I suggest switching "m" to "ssl" - as something that should be everywhere.

And the test should be something more like:

    self.assertEqual(lib not None)

OR is the test actually testing LoadLibrary and CDLL (as well)

Back to my humble opinion: assuming the real test is to test LoadLibrary and CDLL by accepting None as a valid result from find_library - false POSITIVE is the result when find_library() is not working.

----------
messages: 277411
nosy: Michael.Felt
priority: normal
severity: normal
status: open
title: test_loading.py - false positive result for "def test_find" when find_library() is not functional or the (shared) library does not exist
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28276>
_______________________________________


More information about the New-bugs-announce mailing list