@@ -69,7 +69,7 @@ def test(*args: Any, **kwargs: Any) -> None:
69
69
output = run_stubtest (
70
70
stub = "\n \n " .join (textwrap .dedent (c .stub .lstrip ("\n " )) for c in cases ),
71
71
runtime = "\n \n " .join (textwrap .dedent (c .runtime .lstrip ("\n " )) for c in cases ),
72
- options = ["--generate-whitelist" ]
72
+ options = ["--generate-whitelist" ],
73
73
)
74
74
75
75
actual_errors = set (output .splitlines ())
@@ -609,19 +609,23 @@ def test_ignore_flags(self) -> None:
609
609
assert not output
610
610
611
611
def test_whitelist (self ) -> None :
612
- with tempfile .NamedTemporaryFile () as f :
613
- f .write ("{}.bad\n # a comment" .format (TEST_MODULE_NAME ).encode ("utf-8" ))
614
- f .flush ()
612
+ # Can't use this as a context because Windows
613
+ whitelist = tempfile .NamedTemporaryFile (mode = "w" , delete = False )
614
+ try :
615
+ with whitelist :
616
+ whitelist .write ("{}.bad\n # a comment" .format (TEST_MODULE_NAME ))
615
617
616
618
output = run_stubtest (
617
619
stub = "def bad(number: int, text: str) -> None: ..." ,
618
620
runtime = "def bad(num, text) -> None: pass" ,
619
- options = ["--whitelist" , f .name ],
621
+ options = ["--whitelist" , whitelist .name ],
620
622
)
621
623
assert not output
622
624
623
- output = run_stubtest (stub = "" , runtime = "" , options = ["--whitelist" , f .name ])
625
+ output = run_stubtest (stub = "" , runtime = "" , options = ["--whitelist" , whitelist .name ])
624
626
assert output == "note: unused whitelist entry {}.bad\n " .format (TEST_MODULE_NAME )
627
+ finally :
628
+ os .unlink (whitelist .name )
625
629
626
630
def test_mypy_build (self ) -> None :
627
631
output = run_stubtest (stub = "+" , runtime = "" , options = [])
0 commit comments