arminnajafi opened a new pull request, #6607:
URL: https://github.com/apache/iceberg/pull/6607
When running `make test` on mainline branch `test_missing_uri` unit test
fails with:
```
empty_home_dir_path =
'/private/var/folders/wz/yzqdwvrx0cj1j1h5c3g59rm40000gr/T/pytest-of-najarmin/pytest-22/home0'
def test_missing_uri(empty_home_dir_path: str) -> None:
# mock to prevent parsing ~/.pyiceberg.yaml or
{PYICEBERG_HOME}/.pyiceberg.yaml
with mock.patch.dict(os.environ, {"HOME": empty_home_dir_path,
"PYICEBERG_HOME": empty_home_dir_path}):
runner = CliRunner()
result = runner.invoke(run, ["list"])
assert result.exit_code == 1
> assert (
result.output
== "URI missing, please provide using --uri, the config or
environment variable \nPYICEBERG_CATALOG__DEFAULT__URI\n"
)
E AssertionError: assert 'You must specify a region.\n' == 'URI
missing,...EFAULT__URI\n'
E + You must specify a region.
E - URI missing, please provide using --uri, the config or
environment variable
E - PYICEBERG_CATALOG__DEFAULT__URI
tests/cli/test_console.py:144: AssertionError
```
This is because in the PR that introduces this change
(https://github.com/apache/iceberg/pull/6445) needs one more patch. This is
because before we get to the below patch line:
```
# mock to prevent parsing ~/.pyiceberg.yaml or
{PYICEBERG_HOME}/.pyiceberg.yaml
with mock.patch.dict(os.environ, {"HOME": empty_home_dir_path,
"PYICEBERG_HOME": empty_home_dir_path}):
```
`_ENV_CONFIG` is already loaded as part of imports statements in the
`test_console.py` file using the real `$HOME` env:
https://github.com/apache/iceberg/blob/596d7b876dcd9a9d5a5242622e3abaf8f069f3dc/python/pyiceberg/catalog/__init__.py#L51
Therefore a new patch is needed before we call the CLI:
```
with mock.patch('pyiceberg.catalog._ENV_CONFIG', Config()):
```
Just FYI the original config file is as follows at the time of producing
this issue:
```
> cat ~/.pyiceberg.yaml
catalog:
default:
type: glue
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]