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
I am trying to use
postgresql_procwith loading external SQL files, using relative paths, similarly to what is shown in your README. It seems to me thatpytest-postgresqldoes not do anything about the paths, instead using the current working directory as it was when callingpytest. This is quite confusing.My expectation was for the paths to the scripts to be relative to the file in which
postgresql_procis 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:
os.chdir(Path(__file__).parent)at the top ofconftest.pyPath(__file__).parentto the paths for all the SQL files