Skip to content

postgresql_proc file loader and relative paths? #1108

@jaskij

Description

@jaskij

I am trying to use postgresql_proc with loading external SQL files, using relative paths, similarly to what is shown in your README. It seems to me that pytest-postgresql does not do anything about the paths, instead using the current working directory as it was when calling pytest. This is quite confusing.

My expectation was for the paths to the scripts to be relative to the file in which postgresql_proc is called.

One thing that could have caused an issue is that the files are outside the Python package. It's a monorepo with the SQL elsewhere.

I have found two workarounds:

  • call os.chdir(Path(__file__).parent) at the top of conftest.py
  • prepend Path(__file__).parent to the paths for all the SQL files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions