diff options
Diffstat (limited to 'tests/scanner/annotationparser/test_parser.py')
-rw-r--r-- | tests/scanner/annotationparser/test_parser.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/scanner/annotationparser/test_parser.py b/tests/scanner/annotationparser/test_parser.py index 2cec9f11..b676a508 100644 --- a/tests/scanner/annotationparser/test_parser.py +++ b/tests/scanner/annotationparser/test_parser.py @@ -28,9 +28,11 @@ Tests ensuring annotationparser.py continues to function correctly. from __future__ import absolute_import from __future__ import division from __future__ import print_function +from __future__ import unicode_literals import difflib import os +import sys import subprocess import unittest import xml.etree.ElementTree as etree @@ -39,6 +41,11 @@ from giscanner.annotationparser import GtkDocCommentBlockParser, GtkDocCommentBl from giscanner.ast import Namespace from giscanner.message import MessageLogger, WARNING, ERROR, FATAL +if sys.version_info.major < 3: + encode_name = lambda s: s.encode('ascii') +else: + encode_name = lambda s: s + XML_NS = 'http://schemas.gnome.org/gobject-introspection/2013/test' XML_SCHEMA = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tests.xsd')) @@ -399,7 +406,7 @@ def create_test_case(logger, tests_dir, tests_file): for counter, test in enumerate(tests_tree.findall(ns('{}test'))): test_name = 'test_%03d' % (counter + 1) test_method = TestCommentBlock.__create_test__(logger, test) - test_method.__name__ = test_name + test_method.__name__ = encode_name(test_name) test_methods[test_name] = test_method # Dynamically generate a new subclass of TestCommentBlock in TitleCase @@ -407,7 +414,7 @@ def create_test_case(logger, tests_dir, tests_file): test_class_name = os.path.relpath(tests_file[:-4], tests_dir) test_class_name = test_class_name.replace('/', ' ').replace('\\', ' ').replace('.', ' ') test_class_name = 'Test' + test_class_name.title().replace(' ', '') - return type(test_class_name, (TestCommentBlock,), test_methods) + return type(encode_name(test_class_name), (TestCommentBlock,), test_methods) def create_test_cases(): |