HEX
Server: Apache
System: Linux www 6.18.6-i1-amd #905 SMP Mon Jan 19 08:49:07 CET 2026 x86_64
User: sws1073755998 (1073755998)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/ipython_genutils/tests/test_tempdir.py
import os

from ..tempdir import NamedFileInTemporaryDirectory
from ..tempdir import TemporaryWorkingDirectory


def test_named_file_in_temporary_directory():
    with NamedFileInTemporaryDirectory('filename') as file:
        name = file.name
        assert not file.closed
        assert os.path.exists(name)
        file.write(b'test')
    assert file.closed
    assert not os.path.exists(name)

def test_temporary_working_directory():
    with TemporaryWorkingDirectory() as dir:
        assert os.path.exists(dir)
        assert os.path.realpath(os.curdir) == os.path.realpath(dir)
    assert not os.path.exists(dir)
    assert os.path.abspath(os.curdir) != dir