diff options
Diffstat (limited to 'packages/meshbay-hub/tests/test_zipstream.py')
| -rw-r--r-- | packages/meshbay-hub/tests/test_zipstream.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/packages/meshbay-hub/tests/test_zipstream.py b/packages/meshbay-hub/tests/test_zipstream.py index 51a42d0..55a4d97 100644 --- a/packages/meshbay-hub/tests/test_zipstream.py +++ b/packages/meshbay-hub/tests/test_zipstream.py @@ -32,12 +32,12 @@ def _build(files, force_zip64=False, tmp_path=None): # <script type="module">, but Node reads a bare .js as CommonJS unless a # package.json says otherwise, and there is none next to the SPA. module = tmp_path / "zipstream.mjs" - module.write_text(ZIPSTREAM.read_text()) + module.write_text(ZIPSTREAM.read_text(encoding="utf-8"), encoding="utf-8") script = tmp_path / "build.mjs" out = tmp_path / "out.zip" script.write_text(f""" import {{ writeFileSync }} from 'node:fs'; -import {{ ZipStream }} from '{module.as_posix()}'; +import {{ ZipStream }} from '{module.as_uri()}'; const files = {json.dumps({k: list(v) for k, v in files.items()})}; const parts = []; @@ -55,8 +55,8 @@ for (const [name, bytes] of Object.entries(files)) {{ }} await zip.finish(); writeFileSync('{out.as_posix()}', Buffer.concat(parts)); -""") - proc = subprocess.run(["node", str(script)], capture_output=True, text=True) +""", encoding="utf-8") + proc = subprocess.run(["node", str(script)], capture_output=True, text=True, encoding="utf-8") assert proc.returncode == 0, proc.stderr return out.read_bytes() @@ -140,14 +140,14 @@ def test_an_empty_archive_is_still_an_archive(tmp_path): def _under(entries, dir_, tmp_path): module = tmp_path / "zipstream.mjs" - module.write_text(ZIPSTREAM.read_text()) + module.write_text(ZIPSTREAM.read_text(encoding="utf-8"), encoding="utf-8") script = tmp_path / "under.mjs" script.write_text(f""" -import {{ entriesUnder }} from '{module.as_posix()}'; +import {{ entriesUnder }} from '{module.as_uri()}'; const out = entriesUnder({json.dumps(entries)}, {json.dumps(dir_)}); console.log(JSON.stringify(out.map(o => o.name))); -""") - proc = subprocess.run(["node", str(script)], capture_output=True, text=True) +""", encoding="utf-8") + proc = subprocess.run(["node", str(script)], capture_output=True, text=True, encoding="utf-8") assert proc.returncode == 0, proc.stderr return json.loads(proc.stdout) |