Skip to content

IsADirectoryError on open log file #135

Description

@llicour

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))
    ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions