File tree Expand file tree Collapse file tree
sdks/blue-krill/tests/storages Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
1919from pathlib import Path
2020from typing import Callable , Generator , Optional
2121
2222import pytest
2323
24-
2524@pytest .fixture
2625def 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
You can’t perform that action at this time.
0 commit comments