diff --git a/pylint/plugins/hass_enforce_type_hints.py b/pylint/plugins/hass_enforce_type_hints.py index 4092beb3da1..c63fde19c8e 100644 --- a/pylint/plugins/hass_enforce_type_hints.py +++ b/pylint/plugins/hass_enforce_type_hints.py @@ -142,6 +142,7 @@ _TEST_FIXTURES: dict[str, list[str] | str] = { "requests_mock": "requests_mock.Mocker", "snapshot": "SnapshotAssertion", "tmp_path": "Path", + "tmpdir": "py.path.local", } _TEST_FUNCTION_MATCH = TypeHintMatch( function_name="test_*", diff --git a/tests/components/filesize/test_init.py b/tests/components/filesize/test_init.py index effab8f75d8..7c0526b8194 100644 --- a/tests/components/filesize/test_init.py +++ b/tests/components/filesize/test_init.py @@ -1,4 +1,6 @@ """Tests for the Filesize integration.""" +import py + from homeassistant.components.filesize.const import DOMAIN from homeassistant.config_entries import ConfigEntryState from homeassistant.const import CONF_FILE_PATH @@ -10,7 +12,7 @@ from tests.common import MockConfigEntry async def test_load_unload_config_entry( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: str + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local ) -> None: """Test the Filesize configuration entry loading/unloading.""" testfile = f"{tmpdir}/file.txt" @@ -33,7 +35,7 @@ async def test_load_unload_config_entry( async def test_cannot_access_file( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: str + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local ) -> None: """Test that an file not exist is caught.""" mock_config_entry.add_to_hass(hass) @@ -50,7 +52,7 @@ async def test_cannot_access_file( async def test_not_valid_path_to_file( - hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: str + hass: HomeAssistant, mock_config_entry: MockConfigEntry, tmpdir: py.path.local ) -> None: """Test that an invalid path is caught.""" testfile = f"{tmpdir}/file.txt" diff --git a/tests/components/filesize/test_sensor.py b/tests/components/filesize/test_sensor.py index 5b072769f56..bef0eceb653 100644 --- a/tests/components/filesize/test_sensor.py +++ b/tests/components/filesize/test_sensor.py @@ -1,6 +1,8 @@ """The tests for the filesize sensor.""" import os +import py + from homeassistant.const import CONF_FILE_PATH, STATE_UNAVAILABLE from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_component import async_update_entity @@ -24,7 +26,7 @@ async def test_invalid_path( async def test_valid_path( - hass: HomeAssistant, tmpdir: str, mock_config_entry: MockConfigEntry + hass: HomeAssistant, tmpdir: py.path.local, mock_config_entry: MockConfigEntry ) -> None: """Test for a valid path.""" testfile = f"{tmpdir}/file.txt" @@ -46,7 +48,7 @@ async def test_valid_path( async def test_state_unavailable( - hass: HomeAssistant, tmpdir: str, mock_config_entry: MockConfigEntry + hass: HomeAssistant, tmpdir: py.path.local, mock_config_entry: MockConfigEntry ) -> None: """Verify we handle state unavailable.""" testfile = f"{tmpdir}/file.txt" diff --git a/tests/components/http/test_init.py b/tests/components/http/test_init.py index f5a69bd864b..578fcc60c7c 100644 --- a/tests/components/http/test_init.py +++ b/tests/components/http/test_init.py @@ -6,6 +6,7 @@ import logging import pathlib from unittest.mock import Mock, patch +import py import pytest from homeassistant.auth.providers.legacy_api_password import ( @@ -150,7 +151,9 @@ async def test_proxy_config_only_trust_proxies(hass: HomeAssistant) -> None: ) -async def test_ssl_profile_defaults_modern(hass: HomeAssistant, tmpdir) -> None: +async def test_ssl_profile_defaults_modern( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test default ssl profile.""" cert_path, key_path, _ = await hass.async_add_executor_job( @@ -175,7 +178,9 @@ async def test_ssl_profile_defaults_modern(hass: HomeAssistant, tmpdir) -> None: assert len(mock_context.mock_calls) == 1 -async def test_ssl_profile_change_intermediate(hass: HomeAssistant, tmpdir) -> None: +async def test_ssl_profile_change_intermediate( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test setting ssl profile to intermediate.""" cert_path, key_path, _ = await hass.async_add_executor_job( @@ -206,7 +211,9 @@ async def test_ssl_profile_change_intermediate(hass: HomeAssistant, tmpdir) -> N assert len(mock_context.mock_calls) == 1 -async def test_ssl_profile_change_modern(hass: HomeAssistant, tmpdir) -> None: +async def test_ssl_profile_change_modern( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test setting ssl profile to modern.""" cert_path, key_path, _ = await hass.async_add_executor_job( @@ -237,7 +244,7 @@ async def test_ssl_profile_change_modern(hass: HomeAssistant, tmpdir) -> None: assert len(mock_context.mock_calls) == 1 -async def test_peer_cert(hass: HomeAssistant, tmpdir) -> None: +async def test_peer_cert(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test required peer cert.""" cert_path, key_path, peer_cert_path = await hass.async_add_executor_job( _setup_empty_ssl_pem_files, tmpdir @@ -272,7 +279,7 @@ async def test_peer_cert(hass: HomeAssistant, tmpdir) -> None: async def test_emergency_ssl_certificate_when_invalid( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test http can startup with an emergency self signed cert when the current one is broken.""" @@ -303,7 +310,7 @@ async def test_emergency_ssl_certificate_when_invalid( async def test_emergency_ssl_certificate_not_used_when_not_safe_mode( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test an emergency cert is only used in safe mode.""" @@ -320,7 +327,7 @@ async def test_emergency_ssl_certificate_not_used_when_not_safe_mode( async def test_emergency_ssl_certificate_when_invalid_get_url_fails( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test http falls back to no ssl when an emergency cert cannot be created when the configured one is broken. @@ -357,7 +364,7 @@ async def test_emergency_ssl_certificate_when_invalid_get_url_fails( async def test_invalid_ssl_and_cannot_create_emergency_cert( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test http falls back to no ssl when an emergency cert cannot be created when the configured one is broken.""" @@ -388,7 +395,7 @@ async def test_invalid_ssl_and_cannot_create_emergency_cert( async def test_invalid_ssl_and_cannot_create_emergency_cert_with_ssl_peer_cert( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test http falls back to no ssl when an emergency cert cannot be created when the configured one is broken. diff --git a/tests/components/lutron_caseta/test_config_flow.py b/tests/components/lutron_caseta/test_config_flow.py index cc71eb5910f..9518528714b 100644 --- a/tests/components/lutron_caseta/test_config_flow.py +++ b/tests/components/lutron_caseta/test_config_flow.py @@ -3,6 +3,7 @@ import asyncio import ssl from unittest.mock import AsyncMock, patch +import py from pylutron_caseta.pairing import PAIR_CA, PAIR_CERT, PAIR_KEY from pylutron_caseta.smartbridge import Smartbridge import pytest @@ -192,7 +193,7 @@ async def test_already_configured_with_ignored(hass: HomeAssistant) -> None: assert result["type"] == "form" -async def test_form_user(hass: HomeAssistant, tmpdir) -> None: +async def test_form_user(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test we get the form and can pair.""" hass.config.config_dir = await hass.async_add_executor_job( @@ -243,7 +244,9 @@ async def test_form_user(hass: HomeAssistant, tmpdir) -> None: assert len(mock_setup_entry.mock_calls) == 1 -async def test_form_user_pairing_fails(hass: HomeAssistant, tmpdir) -> None: +async def test_form_user_pairing_fails( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test we get the form and we handle pairing failure.""" hass.config.config_dir = await hass.async_add_executor_job( @@ -289,7 +292,7 @@ async def test_form_user_pairing_fails(hass: HomeAssistant, tmpdir) -> None: async def test_form_user_reuses_existing_assets_when_pairing_again( - hass: HomeAssistant, tmpdir + hass: HomeAssistant, tmpdir: py.path.local ) -> None: """Test the tls assets saved on disk are reused when pairing again.""" @@ -390,7 +393,9 @@ async def test_form_user_reuses_existing_assets_when_pairing_again( } -async def test_zeroconf_host_already_configured(hass: HomeAssistant, tmpdir) -> None: +async def test_zeroconf_host_already_configured( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test starting a flow from discovery when the host is already configured.""" hass.config.config_dir = await hass.async_add_executor_job( @@ -474,7 +479,7 @@ async def test_zeroconf_not_lutron_device(hass: HomeAssistant) -> None: @pytest.mark.parametrize( "source", (config_entries.SOURCE_ZEROCONF, config_entries.SOURCE_HOMEKIT) ) -async def test_zeroconf(hass: HomeAssistant, source, tmpdir) -> None: +async def test_zeroconf(hass: HomeAssistant, source, tmpdir: py.path.local) -> None: """Test starting a flow from discovery.""" hass.config.config_dir = await hass.async_add_executor_job( diff --git a/tests/components/profiler/test_init.py b/tests/components/profiler/test_init.py index 636067341e1..0f46f306fef 100644 --- a/tests/components/profiler/test_init.py +++ b/tests/components/profiler/test_init.py @@ -4,6 +4,7 @@ import os import sys from unittest.mock import patch +import py import pytest from homeassistant.components.profiler import ( @@ -25,7 +26,7 @@ import homeassistant.util.dt as dt_util from tests.common import MockConfigEntry, async_fire_time_changed -async def test_basic_usage(hass: HomeAssistant, tmpdir) -> None: +async def test_basic_usage(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test we can setup and the service is registered.""" test_dir = tmpdir.mkdir("profiles") @@ -58,7 +59,7 @@ async def test_basic_usage(hass: HomeAssistant, tmpdir) -> None: @pytest.mark.skipif( sys.version_info >= (3, 11), reason="not yet available on python 3.11" ) -async def test_memory_usage(hass: HomeAssistant, tmpdir) -> None: +async def test_memory_usage(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test we can setup and the service is registered.""" test_dir = tmpdir.mkdir("profiles") @@ -89,7 +90,7 @@ async def test_memory_usage(hass: HomeAssistant, tmpdir) -> None: @pytest.mark.skipif(sys.version_info < (3, 11), reason="still works on python 3.10") -async def test_memory_usage_py311(hass: HomeAssistant, tmpdir) -> None: +async def test_memory_usage_py311(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test raise an error on python3.11.""" entry = MockConfigEntry(domain=DOMAIN) entry.add_to_hass(hass) diff --git a/tests/components/recorder/test_init.py b/tests/components/recorder/test_init.py index 8c1d8ef00aa..48429d7a11d 100644 --- a/tests/components/recorder/test_init.py +++ b/tests/components/recorder/test_init.py @@ -11,6 +11,7 @@ from typing import cast from unittest.mock import Mock, patch from freezegun.api import FrozenDateTimeFactory +import py import pytest from sqlalchemy.exc import DatabaseError, OperationalError, SQLAlchemyError @@ -1222,7 +1223,9 @@ def test_statistics_runs_initiated(hass_recorder: Callable[..., HomeAssistant]) @pytest.mark.freeze_time("2022-09-13 09:00:00+02:00") -def test_compile_missing_statistics(tmpdir, freezer: FrozenDateTimeFactory) -> None: +def test_compile_missing_statistics( + tmpdir: py.path.local, freezer: FrozenDateTimeFactory +) -> None: """Test missing statistics are compiled on startup.""" now = dt_util.utcnow().replace(minute=0, second=0, microsecond=0) test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") @@ -1482,7 +1485,7 @@ def test_service_disable_states_not_recording( ) -def test_service_disable_run_information_recorded(tmpdir) -> None: +def test_service_disable_run_information_recorded(tmpdir: py.path.local) -> None: """Test that runs are still recorded when recorder is disabled.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" @@ -1531,7 +1534,7 @@ class CannotSerializeMe: async def test_database_corruption_while_running( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test we can recover from sqlite3 db corruption.""" diff --git a/tests/components/recorder/test_statistics.py b/tests/components/recorder/test_statistics.py index 46d2c92e463..522a3eff2e6 100644 --- a/tests/components/recorder/test_statistics.py +++ b/tests/components/recorder/test_statistics.py @@ -7,6 +7,7 @@ import importlib import sys from unittest.mock import ANY, DEFAULT, MagicMock, patch, sentinel +import py import pytest from sqlalchemy import create_engine, select from sqlalchemy.exc import OperationalError @@ -1327,7 +1328,9 @@ def _create_engine_28(*args, **kwargs): return engine -def test_delete_metadata_duplicates(caplog: pytest.LogCaptureFixture, tmpdir) -> None: +def test_delete_metadata_duplicates( + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local +) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" @@ -1419,7 +1422,7 @@ def test_delete_metadata_duplicates(caplog: pytest.LogCaptureFixture, tmpdir) -> def test_delete_metadata_duplicates_many( - caplog: pytest.LogCaptureFixture, tmpdir + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local ) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") diff --git a/tests/components/recorder/test_statistics_v23_migration.py b/tests/components/recorder/test_statistics_v23_migration.py index ec36d7eb830..48db847869d 100644 --- a/tests/components/recorder/test_statistics_v23_migration.py +++ b/tests/components/recorder/test_statistics_v23_migration.py @@ -9,6 +9,7 @@ import json import sys from unittest.mock import patch +import py import pytest from sqlalchemy import create_engine from sqlalchemy.orm import Session @@ -52,7 +53,9 @@ def _create_engine_test(*args, **kwargs): return engine -def test_delete_duplicates(caplog: pytest.LogCaptureFixture, tmpdir) -> None: +def test_delete_duplicates( + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local +) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" @@ -222,7 +225,9 @@ def test_delete_duplicates(caplog: pytest.LogCaptureFixture, tmpdir) -> None: assert "Found duplicated" not in caplog.text -def test_delete_duplicates_many(caplog: pytest.LogCaptureFixture, tmpdir) -> None: +def test_delete_duplicates_many( + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local +) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" @@ -400,7 +405,7 @@ def test_delete_duplicates_many(caplog: pytest.LogCaptureFixture, tmpdir) -> Non @pytest.mark.freeze_time("2021-08-01 00:00:00+00:00") def test_delete_duplicates_non_identical( - caplog: pytest.LogCaptureFixture, tmpdir + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local ) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") @@ -572,7 +577,9 @@ def test_delete_duplicates_non_identical( ] -def test_delete_duplicates_short_term(caplog: pytest.LogCaptureFixture, tmpdir) -> None: +def test_delete_duplicates_short_term( + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local +) -> None: """Test removal of duplicated statistics.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" diff --git a/tests/components/recorder/test_util.py b/tests/components/recorder/test_util.py index 6aad3e440df..383a0838430 100644 --- a/tests/components/recorder/test_util.py +++ b/tests/components/recorder/test_util.py @@ -7,6 +7,7 @@ import sqlite3 from unittest.mock import MagicMock, Mock, patch from freezegun import freeze_time +import py import pytest from sqlalchemy import text from sqlalchemy.engine.result import ChunkedIteratorResult @@ -73,7 +74,7 @@ def test_recorder_bad_execute(hass_recorder: Callable[..., HomeAssistant]) -> No def test_validate_or_move_away_sqlite_database( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Ensure a malformed sqlite database is moved away.""" diff --git a/tests/components/recorder/test_v32_migration.py b/tests/components/recorder/test_v32_migration.py index 467dc2961c6..22aa96f8e2f 100644 --- a/tests/components/recorder/test_v32_migration.py +++ b/tests/components/recorder/test_v32_migration.py @@ -6,6 +6,7 @@ import importlib import sys from unittest.mock import patch +import py import pytest from sqlalchemy import create_engine, inspect from sqlalchemy.orm import Session @@ -51,7 +52,9 @@ def _create_engine_test(*args, **kwargs): return engine -async def test_migrate_times(caplog: pytest.LogCaptureFixture, tmpdir) -> None: +async def test_migrate_times( + caplog: pytest.LogCaptureFixture, tmpdir: py.path.local +) -> None: """Test we can migrate times.""" test_db_file = tmpdir.mkdir("sqlite").join("test_run_info.db") dburl = f"{SQLITE_URL_PREFIX}//{test_db_file}" diff --git a/tests/helpers/test_storage.py b/tests/helpers/test_storage.py index 77e5fa4aef8..b60e072d2f1 100644 --- a/tests/helpers/test_storage.py +++ b/tests/helpers/test_storage.py @@ -5,6 +5,7 @@ import json from typing import Any, NamedTuple from unittest.mock import Mock, patch +import py import pytest from homeassistant.const import ( @@ -505,7 +506,7 @@ async def test_changing_delayed_written_data( } -async def test_saving_load_round_trip(tmpdir) -> None: +async def test_saving_load_round_trip(tmpdir: py.path.local) -> None: """Test saving and loading round trip.""" loop = asyncio.get_running_loop() hass = await async_test_home_assistant(loop) diff --git a/tests/helpers/test_storage_remove.py b/tests/helpers/test_storage_remove.py index b90d0df0d03..21eabe80e45 100644 --- a/tests/helpers/test_storage_remove.py +++ b/tests/helpers/test_storage_remove.py @@ -4,13 +4,15 @@ from datetime import timedelta import os from unittest.mock import patch +import py + from homeassistant.helpers import storage from homeassistant.util import dt from tests.common import async_fire_time_changed, async_test_home_assistant -async def test_removing_while_delay_in_progress(tmpdir) -> None: +async def test_removing_while_delay_in_progress(tmpdir: py.path.local) -> None: """Test removing while delay in progress.""" loop = asyncio.get_event_loop() diff --git a/tests/test_runner.py b/tests/test_runner.py index e4af1df2b80..f32321c578c 100644 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -3,6 +3,7 @@ import asyncio import threading from unittest.mock import patch +import py import pytest from homeassistant import core, runner @@ -28,7 +29,7 @@ async def test_cumulative_shutdown_timeout_less_than_supervisor() -> None: ) -async def test_setup_and_run_hass(hass: HomeAssistant, tmpdir) -> None: +async def test_setup_and_run_hass(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test we can setup and run.""" test_dir = tmpdir.mkdir("config") default_config = runner.RuntimeConfig(test_dir) @@ -42,7 +43,7 @@ async def test_setup_and_run_hass(hass: HomeAssistant, tmpdir) -> None: assert mock_run.called -def test_run(hass: HomeAssistant, tmpdir) -> None: +def test_run(hass: HomeAssistant, tmpdir: py.path.local) -> None: """Test we can run.""" test_dir = tmpdir.mkdir("config") default_config = runner.RuntimeConfig(test_dir) @@ -57,7 +58,9 @@ def test_run(hass: HomeAssistant, tmpdir) -> None: assert mock_run.called -def test_run_executor_shutdown_throws(hass: HomeAssistant, tmpdir) -> None: +def test_run_executor_shutdown_throws( + hass: HomeAssistant, tmpdir: py.path.local +) -> None: """Test we can run and we still shutdown if the executor shutdown throws.""" test_dir = tmpdir.mkdir("config") default_config = runner.RuntimeConfig(test_dir) @@ -79,7 +82,7 @@ def test_run_executor_shutdown_throws(hass: HomeAssistant, tmpdir) -> None: def test_run_does_not_block_forever_with_shielded_task( - hass: HomeAssistant, tmpdir, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test we can shutdown and not block forever.""" test_dir = tmpdir.mkdir("config") diff --git a/tests/util/test_file.py b/tests/util/test_file.py index 5934dc689f0..0b87985fe13 100644 --- a/tests/util/test_file.py +++ b/tests/util/test_file.py @@ -3,13 +3,14 @@ import os from pathlib import Path from unittest.mock import patch +import py import pytest from homeassistant.util.file import WriteError, write_utf8_file, write_utf8_file_atomic @pytest.mark.parametrize("func", [write_utf8_file, write_utf8_file_atomic]) -def test_write_utf8_file_atomic_private(tmpdir, func) -> None: +def test_write_utf8_file_atomic_private(tmpdir: py.path.local, func) -> None: """Test files can be written as 0o600 or 0o644.""" test_dir = tmpdir.mkdir("files") test_file = Path(test_dir / "test.json") @@ -25,7 +26,7 @@ def test_write_utf8_file_atomic_private(tmpdir, func) -> None: assert os.stat(test_file).st_mode & 0o777 == 0o600 -def test_write_utf8_file_fails_at_creation(tmpdir) -> None: +def test_write_utf8_file_fails_at_creation(tmpdir: py.path.local) -> None: """Test that failed creation of the temp file does not create an empty file.""" test_dir = tmpdir.mkdir("files") test_file = Path(test_dir / "test.json") @@ -39,7 +40,7 @@ def test_write_utf8_file_fails_at_creation(tmpdir) -> None: def test_write_utf8_file_fails_at_rename( - tmpdir, caplog: pytest.LogCaptureFixture + tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test that if rename fails not not remove, we do not log the failed cleanup.""" test_dir = tmpdir.mkdir("files") @@ -56,7 +57,7 @@ def test_write_utf8_file_fails_at_rename( def test_write_utf8_file_fails_at_rename_and_remove( - tmpdir, caplog: pytest.LogCaptureFixture + tmpdir: py.path.local, caplog: pytest.LogCaptureFixture ) -> None: """Test that if rename and remove both fail, we log the failed cleanup.""" test_dir = tmpdir.mkdir("files") @@ -70,7 +71,7 @@ def test_write_utf8_file_fails_at_rename_and_remove( assert "File replacement cleanup failed" in caplog.text -def test_write_utf8_file_atomic_fails(tmpdir) -> None: +def test_write_utf8_file_atomic_fails(tmpdir: py.path.local) -> None: """Test OSError from write_utf8_file_atomic is rethrown as WriteError.""" test_dir = tmpdir.mkdir("files") test_file = Path(test_dir / "test.json")