pytest-xprocess icon indicating copy to clipboard operation
pytest-xprocess copied to clipboard

IsADirectoryError on open log file

Open llicour opened this issue 2 years ago • 2 comments

Hi. After upgrading from 0.17.1 to 0.22.2, i got following error

  File "/Users/20010116/.pyenv/versions/3.9.17/envs/venv-ddiapi2-py39/lib/python3.9/site-packages/xprocess/pytest_xprocess.py", line 59, in xprocess
    open(log_file, errors="surrogateescape").close()
IsADirectoryError: [Errno 21] Is a directory: '/Users/20010116/Documents/Workspace/ddi/infrasvc-ddi-api/.pytest_cache/d/.xprocess/consumer_start_consumer/log'

Digging the error, i found that get_log_files list all objects in root directory, including directory (i have one that is named "log") I suggest to add a condition to verify if object is a file

def get_log_files(root_dir):
    proc_dirs = [f.path for f in os.scandir(root_dir) if f.is_dir()]
    return [
        os.path.join(proc_dir, f)
        for proc_dir in proc_dirs
        for f in os.listdir(proc_dir)
        if f.endswith("log") and os.path.isfile(os.path.join(proc_dir, f))
    ]

llicour avatar Jul 07 '23 13:07 llicour

Hey @llicour , thanks for taking the time to open the issue! Could you provide a bit more info? Maybe sharing how you are using xprocess? The reason I ask is because there should not be nested directories inside xprocess cache dir at all so we should first understand how this happened before moving further with any changes :bowtie:

northernSage avatar Mar 16 '24 15:03 northernSage

A minimal example to reproduce the issue would go a long way to help this getting fixed

northernSage avatar Mar 16 '24 15:03 northernSage