From: Sarah Hoffmann Date: Mon, 2 Sep 2024 07:49:10 +0000 (+0200) Subject: Merge pull request #3530 from lonvia/clean-use-of-os-environ X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/3e6be0b0be11cb2f398b2fccca91fa502b1a1f51?hp=72be143cef05bf77655cebbfb0f82b8d3426872e Merge pull request #3530 from lonvia/clean-use-of-os-environ Don't use OS environment variables when an explicit environment was set --- diff --git a/src/nominatim_db/config.py b/src/nominatim_db/config.py index 2cab0237..357cc9d7 100644 --- a/src/nominatim_db/config.py +++ b/src/nominatim_db/config.py @@ -61,7 +61,7 @@ class Configuration: def __init__(self, project_dir: Optional[Union[Path, str]], environ: Optional[Mapping[str, str]] = None) -> None: - self.environ = environ or os.environ + self.environ = os.environ if environ is None else environ self.config_dir = paths.CONFIG_DIR self._config = dotenv_values(str(self.config_dir / 'env.defaults')) if project_dir is not None: diff --git a/test/python/api/search/test_icu_query_analyzer.py b/test/python/api/search/test_icu_query_analyzer.py index 473bc149..ac4bcbb7 100644 --- a/test/python/api/search/test_icu_query_analyzer.py +++ b/test/python/api/search/test_icu_query_analyzer.py @@ -38,7 +38,7 @@ async def conn(table_factory): table_factory('word', definition='word_id INT, word_token TEXT, type TEXT, word TEXT, info JSONB') - async with NominatimAPIAsync(environ={}) as api: + async with NominatimAPIAsync() as api: async with api.begin() as conn: yield conn diff --git a/test/python/api/search/test_legacy_query_analyzer.py b/test/python/api/search/test_legacy_query_analyzer.py index a99485ea..7a4d41d3 100644 --- a/test/python/api/search/test_legacy_query_analyzer.py +++ b/test/python/api/search/test_legacy_query_analyzer.py @@ -72,7 +72,7 @@ async def conn(table_factory, temp_db_cursor): temp_db_cursor.execute("""CREATE OR REPLACE FUNCTION make_standard_name(name TEXT) RETURNS TEXT AS $$ SELECT lower(name); $$ LANGUAGE SQL;""") - async with NominatimAPIAsync(environ={}) as api: + async with NominatimAPIAsync() as api: async with api.begin() as conn: yield conn diff --git a/test/python/api/test_api_status.py b/test/python/api/test_api_status.py index 29eb34d0..9341b527 100644 --- a/test/python/api/test_api_status.py +++ b/test/python/api/test_api_status.py @@ -45,7 +45,7 @@ def test_status_full(apiobj, frontend): def test_status_database_not_found(monkeypatch): monkeypatch.setenv('NOMINATIM_DATABASE_DSN', 'dbname=rgjdfkgjedkrgdfkngdfkg') - api = napi.NominatimAPI(environ={}) + api = napi.NominatimAPI() result = api.status()