Coverage for qdscreen/tests/encoding_ref_help.py: 100%
8 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-17 11:02 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-17 11:02 +0000
1# -*- coding: utf-8 -*-
2# the above encoding declaration is needed to have non-ascii characters in this file (anywhere even in comments)
3from __future__ import unicode_literals
5# this module mimics what happens in main.py:
6# - there are special characters in the Foo.__str__ method. To support them in python 2 we need the line 1 (coding)
7# - since in python 2 __str__ is supposed to return bytes, we use @python_2_unicode_compatible
8# - since the special characters in the Foo.__str__ are not ascii, we need them to be declared as unicode literal. For
9# this we can either do it by using a u as in 'u"└─"' or by importing unicode_literals from __future__ (line 2).
10# Note: if we want to have some strings as unicode and some others not we MUST use u"" and not this import.
12from qdscreen.compat import python_2_unicode_compatible, encode_if_py2
15# @python_2_unicode_compatible
16class Foo(object):
17 @encode_if_py2
18 def __str__(self):
19 return u"└─ab\n"
21 # def toto(self):
22 # return "fjdlkdlms"
24 def __repr__(self):
25 return str(self) # + self.toto()