77import xml .etree .ElementTree as ET
88from collections import defaultdict
99from pathlib import Path , PurePath
10- from typing import Any , Dict , Iterator , List , Optional , Tuple
10+ from typing import Any , AnyStr , Dict , Iterator , List , Optional , Tuple
1111from xml .sax .saxutils import escape
1212
1313from . import n , rstparser
@@ -204,7 +204,7 @@ def flush(self) -> None:
204204
205205@contextlib .contextmanager
206206def make_test (
207- files : Dict [PurePath , str ], name : str = ""
207+ files : Dict [PurePath , AnyStr ], name : str = ""
208208) -> Iterator [BackendTestResults ]:
209209 """Create a temporary test project with the given files."""
210210 need_to_make_snooty_toml = Path ("snooty.toml" ) not in files
@@ -222,7 +222,10 @@ def make_test(
222222 file_path = root .joinpath (filename )
223223 if file_path .parent != root :
224224 os .makedirs (file_path .parent , exist_ok = True )
225- file_path .write_text (file_text )
225+ if isinstance (file_text , str ):
226+ file_path .write_text (file_text )
227+ else :
228+ file_path .write_bytes (file_text )
226229
227230 backend = BackendTestResults ()
228231
0 commit comments