From a7826e7e30802dbefc8102d0f796d71e9d49e2e1 Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 24 Apr 2024 15:44:51 +0200 Subject: [PATCH] Update testcontainers version --- pyproject.toml | 2 +- tests/test_test_postgres.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 630a2900..6204b63c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ dev = [ "pytest-xdist", # testcontainers 4.x have issues with Kafka on arm # https://github.com/testcontainers/testcontainers-python/issues/450 - "testcontainers<4.0", + "testcontainers~=4.4.0", "testcontainers-minio", "testcontainers-postgres", "testcontainers-kafka", diff --git a/tests/test_test_postgres.py b/tests/test_test_postgres.py index 87a2c578..e4e03fd0 100644 --- a/tests/test_test_postgres.py +++ b/tests/test_test_postgres.py @@ -1,5 +1,4 @@ import logging -import os import psycopg2 import pytest @@ -23,11 +22,11 @@ def remove_container(): postgres.stop() request.addfinalizer(remove_container) - os.environ["DATACONTRACT_POSTGRES_USERNAME"] = postgres.POSTGRES_USER - os.environ["DATACONTRACT_POSTGRES_PASSWORD"] = postgres.POSTGRES_PASSWORD -def test_test_postgres(postgres_container): +def test_test_postgres(postgres_container, monkeypatch): + monkeypatch.setenv("DATACONTRACT_POSTGRES_USERNAME", postgres.username) + monkeypatch.setenv("DATACONTRACT_POSTGRES_PASSWORD", postgres.password) _init_sql() data_contract_str = _setup_datacontract() @@ -50,9 +49,9 @@ def _setup_datacontract(): def _init_sql(): connection = psycopg2.connect( - database=postgres.POSTGRES_DB, - user=postgres.POSTGRES_USER, - password=postgres.POSTGRES_PASSWORD, + database=postgres.dbname, + user=postgres.username, + password=postgres.password, host=postgres.get_container_host_ip(), port=postgres.get_exposed_port(5432), )