Skip to content

Commit ffb8101

Browse files
committed
fix: remove deprecated function tempfile.mktemp
1 parent eda6815 commit ffb8101

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

sdks/blue-krill/tests/storages/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@
1515
# We undertake not to change the open source license (MIT license) applicable
1616
# to the current version of the project delivered to anyone in the future.
1717

18-
import tempfile as _tempfile_
18+
from tempfile import NamedTemporaryFile
1919
from pathlib import Path
2020
from typing import Callable, Generator, Optional
2121

2222
import pytest
2323

24-
2524
@pytest.fixture
2625
def mktemp() -> Generator[Callable[..., Path], None, None]:
2726
files = []
2827

2928
def core(content: Optional[str] = None):
30-
filepath = Path(_tempfile_.mktemp())
29+
if content is not None:
30+
fh = NamedTemporaryFile(mode="w", delete=False)
31+
fh.write(content)
32+
fh.close()
33+
filepath = Path(fh.name)
34+
else:
35+
fh = NamedTemporaryFile(delete=False)
36+
fh.close()
37+
filepath = Path(fh.name)
3138
files.append(filepath)
32-
if content:
33-
with open(filepath, mode="w") as fh:
34-
fh.write(content)
3539
return filepath
3640

3741
yield core

0 commit comments

Comments
 (0)