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

Unable to start postgres "factories.postgresql_proc"

Open zhangchi1 opened this issue 3 years ago • 1 comments

What action do you want to perform

We are running pytest under image: python:3.7-alpine, with some pre installations:

apk update && apk add postgresql-dev gcc libc-dev linux-headers python3-dev musl-dev && rm -rf /var/cache/apk/*
- psycopg2-binary>=2.9.3
- pytest-postgresql==3.1.3

Example of our code in our test file

socket_dir = tempfile.TemporaryDirectory()
postgresql_my_proc = factories.postgresql_proc(port=None, unixsocketdir=socket_dir.name)
postgresql_my = factories.postgresql("postgresql_my_proc")


@pytest.fixture(scope="function")
def setup_db(postgresql_my):
    def dbcreator():
        return postgresql_my.cursor().connection

    engine = create_engine("postgresql+psycopg2://", creator=dbcreator)
    Base.metadata.create_all(engine)
    Session = sessionmaker(bind=engine)
    session = Session()
    yield session
    session.close()

What are the results

The error that we got

FileNotFoundError: [Errno 2] No such file or directory: '/usr/libexec/postgresql14/pg_ctl': '/usr/libexec/postgresql14/pg_ctl'

It seems like postgresql_proc is not able to find postgresql_proc. Greatly appreciated it if anyone can help us on this issue. 😊

zhangchi1 avatar Mar 24 '22 20:03 zhangchi1

What's the postgresql version installed in your system? What's your test configuration and command you run your tests?

fizyk avatar Mar 28 '22 08:03 fizyk