URL: https://github.com/SSSD/sssd/pull/5651
Author: mtorromeo
 Title: #5651: TEST: Use absolute path for the MODPATH assertions in python 
tests
Action: opened

PR body:
"""
Since 2.5.0 I had these 3 tests fail with the following assertion error:

```
======================================================================
FAIL: testImport (__main__.PyHbacImport)
Import the module and assert it comes from tree
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/sssd/src/sssd-2.5.0/src/tests/pyhbac-test.py", line 91, in 
testImport
    self.assertEqual(pyhbac.__file__, MODPATH + "/pyhbac.so")
AssertionError: '/build/sssd/src/sssd-2.5.0/./tp_pyhbac_za3ox6lp/pyhbac.so' != 
'./tp_pyhbac_za3ox6lp/pyhbac.so'
- /build/sssd/src/sssd-2.5.0/./tp_pyhbac_za3ox6lp/pyhbac.so
+ ./tp_pyhbac_za3ox6lp/pyhbac.so
```

I don't know what changed but the issue here is related to a long-standing bug 
[1] in `tempfile.mkdtemp` where the returned path is not absolute if the dir 
parameter is relative, despite the documentation saying that the returned path 
is always absolute.

[1] https://bugs.python.org/issue7325
"""

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/5651/head:pr5651
git checkout pr5651
From 0b4a328de6775353a34d72b6b5dea1c0aa1de46d Mon Sep 17 00:00:00 2001
From: Massimiliano Torromeo <massimiliano.torro...@gmail.com>
Date: Tue, 25 May 2021 10:37:16 +0200
Subject: [PATCH] TEST: Use absolute path for the MODPATH assertions in python
 tests

---
 src/tests/pyhbac-test.py       | 2 +-
 src/tests/pysss-test.py        | 2 +-
 src/tests/pysss_murmur-test.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tests/pyhbac-test.py b/src/tests/pyhbac-test.py
index 06163afc50..a0775d4523 100755
--- a/src/tests/pyhbac-test.py
+++ b/src/tests/pyhbac-test.py
@@ -27,7 +27,7 @@
 import tempfile
 
 BUILD_DIR = os.getenv('builddir') or "."
-TEST_DIR = os.getenv('SSS_TEST_DIR') or "."
+TEST_DIR = os.path.abspath(os.getenv('SSS_TEST_DIR') or ".")
 MODPATH = tempfile.mkdtemp(prefix="tp_pyhbac_", dir=TEST_DIR)
 
 
diff --git a/src/tests/pysss-test.py b/src/tests/pysss-test.py
index 30bc074abd..9ecaed9ec6 100755
--- a/src/tests/pysss-test.py
+++ b/src/tests/pysss-test.py
@@ -26,7 +26,7 @@
 import tempfile
 
 BUILD_DIR = os.getenv('builddir') or "."
-TEST_DIR = os.getenv('SSS_TEST_DIR') or "."
+TEST_DIR = os.path.abspath(os.getenv('SSS_TEST_DIR') or ".")
 MODPATH = tempfile.mkdtemp(prefix="tp_pysss_", dir=TEST_DIR)
 
 
diff --git a/src/tests/pysss_murmur-test.py b/src/tests/pysss_murmur-test.py
index 531f8b55f6..89d5077b70 100755
--- a/src/tests/pysss_murmur-test.py
+++ b/src/tests/pysss_murmur-test.py
@@ -25,7 +25,7 @@
 import tempfile
 
 BUILD_DIR = os.getenv('builddir') or "."
-TEST_DIR = os.getenv('SSS_TEST_DIR') or "."
+TEST_DIR = os.path.abspath(os.getenv('SSS_TEST_DIR') or ".")
 MODPATH = tempfile.mkdtemp(prefix="tp_pysss_murmur_", dir=TEST_DIR)
 
 
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org
Do not reply to spam on the list, report it: 
https://pagure.io/fedora-infrastructure

Reply via email to