diff --git a/.github/workflows/contrib_rerun_py.yml b/.github/workflows/contrib_rerun_py.yml index 38e0ed4d135b..c81c2b12f5c2 100644 --- a/.github/workflows/contrib_rerun_py.yml +++ b/.github/workflows/contrib_rerun_py.yml @@ -93,7 +93,7 @@ jobs: - name: Run unit tests shell: bash - run: cd rerun_py/tests && pytest + run: cd rerun_py/tests && pytest -c ../pyproject.toml - name: Run e2e test shell: bash diff --git a/.github/workflows/reusable_build_and_test_wheels.yml b/.github/workflows/reusable_build_and_test_wheels.yml index 2ddae31ac99e..1d45dcd4b6b3 100644 --- a/.github/workflows/reusable_build_and_test_wheels.yml +++ b/.github/workflows/reusable_build_and_test_wheels.yml @@ -245,7 +245,7 @@ jobs: - name: Run unit tests if: needs.set-config.outputs.RUN_TESTS == 'true' shell: bash - run: cd rerun_py/tests && pytest + run: cd rerun_py/tests && pytest -c ../pyproject.toml - name: Run e2e test if: needs.set-config.outputs.RUN_TESTS == 'true' diff --git a/justfile b/justfile index b4d519a7cae4..d011861c70f0 100644 --- a/justfile +++ b/justfile @@ -113,7 +113,7 @@ py-lint: # Run fast unittests py-test: - python -m pytest -vv rerun_py/tests/unit/ + python -m pytest -vv -c rerun_py/pyproject.toml rerun_py/tests/unit/ # Run tests on all supported Python versions (through nox) py-test-allpy: diff --git a/rerun_py/pyproject.toml b/rerun_py/pyproject.toml index 31149866e904..777826f99280 100644 --- a/rerun_py/pyproject.toml +++ b/rerun_py/pyproject.toml @@ -119,3 +119,10 @@ include = ["rerun_sdk.pth", "rerun_sdk/rerun_demo/colmap_fiat.rrd"] locked = true name = "rerun_bindings" # name of the .so library that the Python module will import python-packages = ["rerun_sdk/rerun", "rerun_sdk/rerun_demo"] + +[tool.pytest.ini_options] +# These conform to Python's Warning Filter syntax: +# https://docs.python.org/3/library/warnings.html#warning-filter +filterwarnings = """ +error +""" diff --git a/rerun_py/rerun_sdk/rerun/_image.py b/rerun_py/rerun_sdk/rerun/_image.py index 3bc106c0db4d..226d8589c569 100644 --- a/rerun_py/rerun_sdk/rerun/_image.py +++ b/rerun_py/rerun_sdk/rerun/_image.py @@ -102,9 +102,9 @@ def __init__( if (path is None) == (contents is None): raise ValueError("Must provide exactly one of 'path' or 'contents'") - buffer: IO[bytes] | None = None + buffer: IO[bytes] | None if path is not None: - buffer = open(path, "rb") + buffer = io.BytesIO(pathlib.Path(path).read_bytes()) elif isinstance(contents, bytes): buffer = io.BytesIO(contents) else: diff --git a/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py b/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py index 31981d1d3fa0..e9477fa03e4f 100644 --- a/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py +++ b/rerun_py/rerun_sdk/rerun/archetypes/asset3d_ext.py @@ -74,7 +74,7 @@ def __init__( if path is None: blob = contents else: - blob = open(path, "rb").read() + blob = pathlib.Path(path).read_bytes() if media_type is None: media_type = guess_media_type(str(path))