From fcabbf09d85397e244f6486d6eca25e2366b61cd Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 21 Feb 2023 15:35:38 +0000 Subject: Tests: added Python tests with encoding. --- test/python/unicode/wsgi.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/python/unicode/wsgi.py (limited to 'test/python/unicode/wsgi.py') diff --git a/test/python/unicode/wsgi.py b/test/python/unicode/wsgi.py new file mode 100644 index 00000000..40043af9 --- /dev/null +++ b/test/python/unicode/wsgi.py @@ -0,0 +1,8 @@ +def application(environ, start_response): + temp_dir = environ.get('HTTP_TEMP_DIR') + + with open(temp_dir + '/tempfile', 'w') as f: + f.write('\u26a0\ufe0f') + + start_response('200', [('Content-Length', '0')]) + return [] -- cgit From 7934dcabbc3c2b585e8d3f8fcee7020ba26f1687 Mon Sep 17 00:00:00 2001 From: Andrei Zeliankou Date: Tue, 21 Feb 2023 17:21:29 +0000 Subject: Tests: switched to using f-strings. Previously, it was necessary to support older versions of Python for compatibility. F-strings were released in Python 3.6. Python 3.5 was marked as unsupported by the end of 2020, so now it's possible to start using f-strings safely for better readability and performance. --- test/python/unicode/wsgi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/python/unicode/wsgi.py') diff --git a/test/python/unicode/wsgi.py b/test/python/unicode/wsgi.py index 40043af9..f2f85f5d 100644 --- a/test/python/unicode/wsgi.py +++ b/test/python/unicode/wsgi.py @@ -1,7 +1,7 @@ def application(environ, start_response): temp_dir = environ.get('HTTP_TEMP_DIR') - with open(temp_dir + '/tempfile', 'w') as f: + with open(f'{temp_dir}/tempfile', 'w') as f: f.write('\u26a0\ufe0f') start_response('200', [('Content-Length', '0')]) -- cgit