3 if sys.version_info >= (3, 0):
5 for tests that need to test long values in python 2
7 python 3 does not differentiate between long and int
8 and does not supply a long keyword
10 instead of testing longs by using values such as 10L
11 test writters should do this:
13 from compathelper import _long
19 for tests that need to test string values in python 2
21 python 3 does differentiate between str and bytes
22 and does not supply a basestring keyword
24 any tests that use basestring should do this:
26 from compathelper import _basestring
27 isinstance(_basestring, "hello")
32 for tests that need to write to intefaces that take bytes in
35 python 3 has a seperate bytes type for low level functions like os.write
37 python 2 treats these as strings
39 any tests that need to write a string of bytes should do something like
42 from compathelper import _bytes
43 os.write(_bytes("hello"))
46 _bytes = lambda s: s.encode()
49 for tests that need to write to intefaces that take unicode in
52 python 3 strings are unicode encoded as UTF-8 so the unicode object
55 python 2 differs between a string an unicode string and you must specify
56 an encoding. This macro will specify UTF-8 in python 2
58 any tests that need to use unicode should do this
60 from compathelper import _unicode
61 unicode_string = _unicode('this is a unicode string')
64 _unicode = lambda s: str(s)
67 _basestring = basestring
69 _unicode = lambda s: unicode(s, 'UTF-8')