diff --git a/tests/test___main__.py b/tests/test___main__.py index ebd48bf5..9fadbed2 100644 --- a/tests/test___main__.py +++ b/tests/test___main__.py @@ -20,10 +20,13 @@ def _test_cli_with_md5(url_or_id, md5, options=None): def _test_cli_with_content(url_or_id, content): - with tempfile.NamedTemporaryFile() as f: - cmd = ["gdown", "--no-cookies", url_or_id, "-O", f.name] + # We can't use NamedTemporaryFile because Windows doesn't allow the subprocess + # to write the file created by the parent process. + with tempfile.TemporaryDirectory() as d: + file_path = os.path.join(d, "file") + cmd = ["gdown", "--no-cookies", url_or_id, "-O", file_path] subprocess.call(cmd) - with open(f.name) as f: + with open(file_path) as f: assert f.read() == content