Skip to content

Commit aa1eb41

Browse files
committed
test: fix codemap test in python3.15
1 parent b6e5067 commit aa1eb41

2 files changed

Lines changed: 19 additions & 17 deletions

File tree

‎test/fixtures/test-charmap.py‎

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
import sys
21
import locale
32

4-
try:
5-
reload(sys)
6-
except NameError: # Python 3
7-
pass
3+
# Must stay in sync with the directory names in test-addon.js. Each name has
4+
# to be encodable in the code page it is keyed under: the MSVC toolchain
5+
# converts paths through the ANSI code page, so a name that only survives as
6+
# Unicode will fail to open at link time.
7+
TEXTMAP = {
8+
"cp936": "文件夹",
9+
"cp1252": "Latína",
10+
"cp932": "フォルダ",
11+
}
812

913

1014
def main():
1115
encoding = locale.getdefaultlocale()[1]
1216
if not encoding:
1317
return False
1418

19+
text = TEXTMAP.get(encoding)
20+
if text is None:
21+
return True
22+
1523
try:
16-
sys.setdefaultencoding(encoding)
17-
except AttributeError: # Python 3
18-
pass
19-
20-
textmap = {
21-
"cp936": "\u4e2d\u6587",
22-
"cp1252": "Lat\u012bna",
23-
"cp932": "\u306b\u307b\u3093\u3054",
24-
}
25-
if encoding in textmap:
26-
print(textmap[encoding])
24+
text.encode(encoding)
25+
except UnicodeEncodeError:
26+
return False
27+
28+
print(text)
2729
return True
2830

2931

‎test/test-addon.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('addon', function () {
6868
// Select non-ascii characters by current encoding
6969
const testDirName = {
7070
cp936: '文件夹',
71-
cp1252: 'Latīna',
71+
cp1252: 'Latína',
7272
cp932: 'フォルダ'
7373
}[getEncoding()]
7474
// If encoding is UTF-8 or other then no need to test

0 commit comments

Comments
 (0)