diff --git a/src/OFS/tests/testObjectManager.py b/src/OFS/tests/testObjectManager.py index 555919eaea..f434c6c71c 100644 --- a/src/OFS/tests/testObjectManager.py +++ b/src/OFS/tests/testObjectManager.py @@ -614,7 +614,6 @@ def test_export_import(self): from transaction import commit try: tf = None # temporary file required for export/import - tdir_created = False # export/import needs the object manager in ZODB s = DemoStorage() db = DB(s) @@ -628,18 +627,15 @@ def test_export_import(self): top._setObject(tmp.getId(), tmp) commit() exported = top.manage_exportObject("f", True) - if tempfile.tempdir is None: # pragma: no cover - tempfile.mktemp() # initialize `tempdir` - tdir = join(tempfile.tempdir, "import") - if not exists(tdir): # pragma: no cover - tdir_created = True - mkdir(tdir) + tdir = tempfile.mkdtemp() + idir = join(tdir, "import") + mkdir(idir) tf = tempfile.NamedTemporaryFile( - dir=tdir, delete=False) + dir=idir, delete=False) tf.write(exported) tf.close() unused, tname = split(tf.name) - tmp._getImportPaths = _CallResult((tempfile.tempdir,)) + tmp._getImportPaths = _CallResult((tdir,)) tmp.manage_importObject(tname, set_owner=False, suppress_events=True) imp_f = tmp["f"] # exception if import unsuccessful @@ -648,7 +644,7 @@ def test_export_import(self): finally: if tf is not None: # pragma: no cover unlink(tf.name) - if tdir_created: # pragma: no cover + rmdir(idir) rmdir(tdir) c.close() db.close()