From 0db5c3ed350819eaa9f13dd871500cd74f88d9fd Mon Sep 17 00:00:00 2001 From: Nathan Clack Date: Wed, 14 Dec 2022 16:22:57 -0800 Subject: [PATCH] fix flaky fetch tests (#255) * fix flaky fetch tests * style: [pre-commit.ci] auto fixes [...] Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- npe2/cli.py | 2 +- npe2/manifest/_bases.py | 2 +- tests/test_fetch.py | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/npe2/cli.py b/npe2/cli.py index 05ca303c..165e6654 100644 --- a/npe2/cli.py +++ b/npe2/cli.py @@ -386,7 +386,7 @@ def fetch( manifest_string = getattr(mf, fmt.value)(**kwargs) if output: - output.write_text(manifest_string) + output.write_text(manifest_string, encoding="utf-8") else: _pprint_formatted(manifest_string, fmt) diff --git a/npe2/manifest/_bases.py b/npe2/manifest/_bases.py index 3162f94f..f7ddca06 100644 --- a/npe2/manifest/_bases.py +++ b/npe2/manifest/_bases.py @@ -80,7 +80,7 @@ def from_file(cls, path: Union[Path, str]): else: raise ValueError(f"unrecognized file extension: {path}") # pragma: no cover - with open(path) as f: + with open(path, encoding="utf-8") as f: data = loader(f) or {} if path.name == "pyproject.toml": diff --git a/tests/test_fetch.py b/tests/test_fetch.py index cc5f964f..0d6748f2 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -94,7 +94,7 @@ def test_get_manifest_from_wheel(tmp_path): def test_get_hub_plugins(): plugins = get_hub_plugins() - assert "napari-svg" in plugins + assert len(plugins) > 0 def test_get_hub_plugin(): @@ -103,8 +103,8 @@ def test_get_hub_plugin(): def test_get_pypi_plugins(): - info = get_pypi_plugins() - assert "napari-svg" in info + plugins = get_pypi_plugins() + assert len(plugins) > 0 @pytest.mark.skipif(not os.getenv("CI"), reason="slow, only run on CI")