Ignore:
Timestamp:
22 Jun 2013, 21:35:05 (11 years ago)
Author:
uli
Message:

Modify tempfile.tempdir on test runs to remove really all tempdirs created during tests by mkdtemp().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/tests/test_server.py

    r10335 r10348  
    1111
    1212    def setUp(self):
    13         self.workdir = tempfile.mkdtemp()
     13        # Create a new location where tempfiles are created.  This way
     14        # also temporary dirs of local CASServers can be removed on
     15        # tear-down.
     16        self._new_tmpdir = tempfile.mkdtemp()
     17        self._old_tmpdir = tempfile.tempdir
     18        tempfile.tempdir = self._new_tmpdir
     19        self.workdir = os.path.join(self._new_tmpdir, 'home')
     20        self.db_path = os.path.join(self.workdir, 'mycas.db')
    1421        self.paste_conf1 = os.path.join(
    1522            os.path.dirname(__file__), 'sample1.ini')
    1623
    1724    def tearDown(self):
    18         shutil.rmtree(self.workdir)
     25        # remove local tempfile and reset old tempdir setting
     26        if os.path.isdir(self._new_tmpdir):
     27            shutil.rmtree(self._new_tmpdir)
     28        tempfile.tempdir = self._old_tmpdir
    1929
    2030    def test_paste_deploy_loader(self):
Note: See TracChangeset for help on using the changeset viewer.