Skip to content

Commit 171d0e5

Browse files
xiaoj655narasux
andauthored
fix: remove deprecated function tempfile.mktemp (#268)
Co-authored-by: narasux <suzh9@mail2.sysu.edu.cn>
1 parent 1c675e5 commit 171d0e5

3 files changed

Lines changed: 38 additions & 51 deletions

File tree

sdks/blue-krill/poetry.lock

Lines changed: 29 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/blue-krill/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ moto = "^2.3.2"
5050
django-rest-framework = "^0.1.0"
5151
celery = "^5.0.5"
5252
# pytest
53-
pytest = "^6.2.2"
53+
pytest = ">=7,<8"
5454
pytest-django = "^4.1.0"
5555
# mypy
5656
mypy = "^1.19.0"

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,25 @@
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())
31-
files.append(filepath)
32-
if content:
33-
with open(filepath, mode="w") as fh:
29+
if content is not None:
30+
with NamedTemporaryFile(mode="w", delete=False) as fh:
3431
fh.write(content)
32+
filepath = Path(fh.name)
33+
else:
34+
with NamedTemporaryFile(delete=False) as fh:
35+
filepath = Path(fh.name)
36+
files.append(filepath)
3537
return filepath
3638

3739
yield core

0 commit comments

Comments
 (0)