-@pytest.fixture
-def tmp_phplib_dir():
- with tempfile.TemporaryDirectory() as phpdir:
- (Path(phpdir) / 'admin').mkdir()
-
- yield Path(phpdir)
-
-@pytest.fixture
-def nominatim_env(tmp_phplib_dir, def_config):
- class _NominatimEnv:
- config = def_config
- phplib_dir = tmp_phplib_dir
- data_dir = Path('data')
- project_dir = Path('.')
- sqllib_dir = Path('lib-sql')
- config_dir = Path('settings')
- module_dir = 'module'
- osm2pgsql_path = 'osm2pgsql'
-
- return _NominatimEnv
-
-@pytest.fixture
-def test_script(nominatim_env):
- def _create_file(code):
- with (nominatim_env.phplib_dir / 'admin' / 't.php').open(mode='w') as fd:
- fd.write('<?php\n')
- fd.write(code + '\n')