Skip to content

Commit 799fe95

Browse files
committed
add test
1 parent 97f7c2c commit 799fe95

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/cpyext/test_unicode.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@
4040
import locale
4141
import re
4242
import sys
43+
import os
4344
import unittest
4445

4546
from . import CPyExtType, CPyExtTestCase, CPyExtFunction, unhandled_error_compare, GRAALPYTHON, CPyExtFunctionOutVars, \
4647
is_native_object
4748

49+
from test.support import os_helper
4850

4951
def _reference_fromobject(args):
5052
if isinstance(args[0], str):
@@ -1056,6 +1058,27 @@ class TestPyUnicode(CPyExtTestCase):
10561058
arguments=["const char* encoding", "const char* object", "Py_ssize_t length", "Py_ssize_t start", "Py_ssize_t end", "const char* reason"]
10571059
)
10581060

1061+
test_PyUnicode_FSDecoder = CPyExtFunction(
1062+
lambda args: str(args[0]),
1063+
lambda: (
1064+
(os.path.realpath(os_helper.TESTFN),),
1065+
),
1066+
code='''PyObject* wrap_PyUnicode_FSDecoder(PyObject* path) {
1067+
PyObject* res;
1068+
int ret = PyUnicode_FSDecoder(path, &res);
1069+
if (ret <= 0 && PyErr_Occurred()) {
1070+
return NULL;
1071+
}
1072+
return res;
1073+
}
1074+
''',
1075+
resultspec="O",
1076+
argspec='O',
1077+
arguments=["PyObject* path"],
1078+
callfunction="wrap_PyUnicode_FSDecoder",
1079+
cmpfunc=unhandled_error_compare
1080+
)
1081+
10591082

10601083
class TestUnicodeObject(unittest.TestCase):
10611084
def test_intern(self):

0 commit comments

Comments
 (0)