URL:
https://github.com/SSSD/sssd/pull/5636
Author: sergiodj
Title: #5636: Improve assertion when verifying paths for Python modules
Action: opened
PR body:
"""
In Ubuntu we're facing a problem where the 3 Python tests under
src/tests/*-test.py are failing due to cosmetical differences between
what the '.__file__' method returns and what 'MODPATH' ends up being.
I have not been able to pinpoint exactly what is causing this issue;
it only happens when SSSD is built inside a chroot environment (with
sbuild, for example). The logs look like this:
```python
F
======================================================================
FAIL: testImport (__main__.PyHbacImport)
Import the module and assert it comes from tree
----------------------------------------------------------------------
Traceback (most recent call last):
File "/<<PKGBUILDDIR>>/src/tests/pyhbac-test.py", line 91, in
testImport
self.assertEqual(pyhbac.__file__, MODPATH + "/pyhbac.so")
AssertionError:
'/<<PKGBUILDDIR>>/build/./tp_pyhbac_xw2omut2/pyhbac.so' !=
'./tp_pyhbac_xw2omut2/pyhbac.so'
- /<<PKGBUILDDIR>>/build/./tp_pyhbac_xw2omut2/pyhbac.so
+ ./tp_pyhbac_xw2omut2/pyhbac.so
```
Given that the intention of the test is to verify that the two paths
are equal, I suggest that we do this slight improvement and call
'os.path.realpath' before comparing both paths. This way we guarantee
that they're both properly canonicalized.
I have verified that the tests still pass with this change.
"""
To pull the PR as Git branch:
git remote add ghsssd
https://github.com/SSSD/sssd
git fetch ghsssd pull/5636/head:pr5636
git checkout pr5636