1010#
1111
1212import os
13- import shutil
1413import pytest
15- import secrets
1614import typing as t
1715from pathlib import Path
1816from dataclasses import dataclass
@@ -45,17 +43,15 @@ class CLIMessages:
4543
4644
4745@pytest .fixture (name = "cfp_setup" , scope = "function" )
48- def fixture_cfp_setup (tmp_path : Path ) -> Callable [..., t .ContextManager [CryptoFilePaths ]]:
46+ def fixture_cfp_setup (alt_tmp_path ) -> Callable [..., t .ContextManager [CryptoFilePaths ]]:
4947 @contextmanager
5048 def closure (algorithm : str ) -> t .Generator [CryptoFilePaths , t .Any , None ]:
51- sub_path = tmp_path / secrets .token_hex (16 )
52- sub_path .mkdir (parents = True , exist_ok = True )
5349 cfp_dict = dict (
54- public_key_fp = sub_path / f"{ algorithm } -pubkey.qc" ,
55- secret_key_fp = sub_path / f"{ algorithm } -seckey.qc" ,
56- ciphertext_fp = sub_path / "ciphertext.kptn" ,
57- plaintext_fp = sub_path / "plaintext.bin" ,
58- signature_fp = sub_path / "signature.sig" ,
50+ public_key_fp = alt_tmp_path / f"{ algorithm } -pubkey.qc" ,
51+ secret_key_fp = alt_tmp_path / f"{ algorithm } -seckey.qc" ,
52+ ciphertext_fp = alt_tmp_path / "ciphertext.kptn" ,
53+ plaintext_fp = alt_tmp_path / "plaintext.bin" ,
54+ signature_fp = alt_tmp_path / "signature.sig" ,
5955 ptf_data = os .urandom (1024 )
6056 )
6157 cfp = CryptoFilePaths (** {
@@ -65,7 +61,7 @@ def closure(algorithm: str) -> t.Generator[CryptoFilePaths, t.Any, None]:
6561 with open (cfp .plaintext_fp , "wb" ) as file :
6662 file .write (cfp .ptf_data )
6763 cwd = os .getcwd ()
68- os .chdir (sub_path )
64+ os .chdir (alt_tmp_path )
6965 yield cfp
7066 os .chdir (cwd )
7167 return closure
0 commit comments