diff options
author | Lukas Slebodnik <lslebodn@redhat.com> | 2015-05-21 13:20:35 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-05-26 15:10:56 +0200 |
commit | 62b20154899f847e760d6dfbae6a32fb45b448de (patch) | |
tree | 00542b897c2e8762f1a583f301a93f485257c04f /src/config/SSSDConfigTest.py | |
parent | cc98e19b424861c2a7fd91e0d657d82c1dbf3059 (diff) | |
download | sssd-62b20154899f847e760d6dfbae6a32fb45b448de.tar.gz sssd-62b20154899f847e760d6dfbae6a32fb45b448de.tar.xz sssd-62b20154899f847e760d6dfbae6a32fb45b448de.zip |
SSSDConfigTest: Use unique temporary directory
Test SSSDConfigTest is executed twice with make check
if python2 and python3 are available.
Tests are executed in parallel with new automake
and therefore it caused sometimes failures e.g.
ERROR: testModifyExistingConfig (__main__.SSSDConfigTestValid)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/tmp/sssd/src/config/SSSDConfigTest.py", line 215, in testModifyExistingConfig
mode = os.stat(of)[ST_MODE]
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/testModifyExistingConfig.conf'
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Diffstat (limited to 'src/config/SSSDConfigTest.py')
-rwxr-xr-x | src/config/SSSDConfigTest.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py index db16bc433..ab9d51211 100755 --- a/src/config/SSSDConfigTest.py +++ b/src/config/SSSDConfigTest.py @@ -6,6 +6,8 @@ Created on Sep 18, 2009 ''' import unittest import os +import shutil +import tempfile from stat import * import sys @@ -19,12 +21,17 @@ else: import SSSDConfig +def create_temp_dir(): + test_dir = os.environ.get('SSS_TEST_DIR') or "." + return tempfile.mkdtemp(dir=test_dir) + + class SSSDConfigTestValid(unittest.TestCase): def setUp(self): - pass + self.tmp_dir = create_temp_dir() def tearDown(self): - pass + shutil.rmtree(self.tmp_dir) def testServices(self): sssdconfig = SSSDConfig.SSSDConfig(srcdir + "/etc/sssd.api.conf", @@ -132,7 +139,7 @@ class SSSDConfigTestValid(unittest.TestCase): local_domain.set_active(True) sssdconfig.save_domain(local_domain) - of = '/tmp/testCreateNewLocalConfig.conf' + of = self.tmp_dir + '/testCreateNewLocalConfig.conf' #Ensure the output file doesn't exist try: @@ -166,7 +173,7 @@ class SSSDConfigTestValid(unittest.TestCase): ldap_domain.set_active(True) sssdconfig.save_domain(ldap_domain) - of = '/tmp/testCreateNewLDAPConfig.conf' + of = self.tmp_dir + '/testCreateNewLDAPConfig.conf' #Ensure the output file doesn't exist try: @@ -200,7 +207,7 @@ class SSSDConfigTestValid(unittest.TestCase): ldap_domain.set_active(True) sssdconfig.save_domain(ldap_domain) - of = '/tmp/testModifyExistingConfig.conf' + of = self.tmp_dir + '/testModifyExistingConfig.conf' #Ensure the output file doesn't exist try: @@ -1134,10 +1141,10 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase): class SSSDConfigTestSSSDConfig(unittest.TestCase): def setUp(self): - pass + self.tmp_dir = create_temp_dir() def tearDown(self): - pass + shutil.rmtree(self.tmp_dir) def testInit(self): # Positive test @@ -1753,7 +1760,7 @@ class SSSDConfigTestSSSDConfig(unittest.TestCase): sssdconfig.save_domain(domain) - of = '/tmp/testSaveDomain.out' + of = self.tmp_dir + '/testSaveDomain.out' #Ensure the output file doesn't exist try: |