Skip to content

Commit 881a46e

Browse files
committed
Test on windows
1 parent f631877 commit 881a46e

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

test/test_utf8_encoding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
import python_minifier
34
import tempfile

test/test_windows_encoding_regression.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# -*- coding: utf-8 -*-
12
import pytest
23
import tempfile
34
import os
@@ -32,10 +33,10 @@ def test_cli_output_flag_with_unicode():
3233
result = subprocess.run([
3334
sys.executable, '-m', 'python_minifier',
3435
source_path, '--output', output_path
35-
], capture_output=True, text=False, timeout=30)
36+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
3637

3738
# Test should fail if CLI command fails (indicates Windows encoding bug)
38-
assert result.returncode == 0, f"CLI failed with encoding error: {result.stderr}"
39+
assert result.returncode == 0, "CLI failed with encoding error: {}".format(result.stderr)
3940

4041
# Verify the output file was created and contains Unicode characters
4142
with open(output_path, 'r', encoding='utf-8') as f:
@@ -74,10 +75,10 @@ def test_cli_in_place_with_unicode():
7475
result = subprocess.run([
7576
sys.executable, '-m', 'python_minifier',
7677
temp_path, '--in-place'
77-
], capture_output=True, text=True, timeout=30)
78+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
7879

7980
# Test should fail if CLI command fails (indicates Windows encoding bug)
80-
assert result.returncode == 0, f"CLI failed with encoding error: {result.stderr}"
81+
assert result.returncode == 0, "CLI failed with encoding error: {}".format(result.stderr)
8182

8283
# Verify Unicode characters are preserved in the modified file
8384
with open(temp_path, 'r', encoding='utf-8') as f:
@@ -108,13 +109,13 @@ def test_cli_stdout_with_unicode():
108109

109110
try:
110111
# Run without --output or --in-place (should output to stdout)
111-
# Use text=False to avoid subprocess decoding issues with Windows
112+
# Use stdout=PIPE, stderr=PIPE to avoid subprocess decoding issues with Windows
112113
# We'll manually decode as UTF-8 to properly handle Unicode characters
113114
result = subprocess.run([
114115
sys.executable, '-m', 'python_minifier', temp_path
115-
], capture_output=True, text=False, timeout=30)
116+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=30)
116117

117-
assert result.returncode == 0, f"Stdout output failed: {result.stderr.decode('utf-8', errors='replace')}"
118+
assert result.returncode == 0, "Stdout output failed: {}".format(result.stderr.decode('utf-8', errors='replace'))
118119

119120
# Decode stdout and verify Unicode characters are present
120121
stdout_text = result.stdout.decode('utf-8', errors='replace')
@@ -137,7 +138,7 @@ def test_windows_default_encoding_detection():
137138
default_encoding = locale.getpreferredencoding()
138139

139140
# On problematic Windows systems, this is often cp1252, gbk, or similar
140-
print(f"Windows default encoding: {default_encoding}")
141+
print("Windows default encoding: {}".format(default_encoding))
141142

142143
# This test documents the encoding environment for debugging
143144
assert default_encoding is not None
@@ -146,10 +147,10 @@ def test_windows_default_encoding_detection():
146147
def test_system_encoding_info():
147148
"""Diagnostic test to understand system encoding setup."""
148149

149-
print(f"System default encoding: {sys.getdefaultencoding()}")
150-
print(f"Filesystem encoding: {sys.getfilesystemencoding()}")
151-
print(f"Preferred encoding: {locale.getpreferredencoding()}")
152-
print(f"Platform: {sys.platform}")
150+
print("System default encoding: {}".format(sys.getdefaultencoding()))
151+
print("Filesystem encoding: {}".format(sys.getfilesystemencoding()))
152+
print("Preferred encoding: {}".format(locale.getpreferredencoding()))
153+
print("Platform: {}".format(sys.platform))
153154

154155
# This test always passes but provides diagnostic information
155156
assert True

0 commit comments

Comments
 (0)