summaryrefslogtreecommitdiff
path: root/tests/compathelper.py
blob: d4f4d27c59e95802b85075c4fbd1f901c9611ce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys

PY2 = PY3 = False

if sys.version_info >= (3, 0):
    '''
    for tests that need to test long values in python 2

    python 3 does not differentiate between long and int
    and does not supply a long keyword

    instead of testing longs by using values such as 10L
    test writters should do this:

    from compathelper import _long
    _long(10)
    '''
    _long = int

    '''
    for tests that need to test string values in python 2

    python 3 does differentiate between str and bytes
    and does not supply a basestring keyword

    any tests that use basestring should do this:

    from compathelper import _basestring
    isinstance(_basestring, "hello")
    '''
    _basestring = str

    from io import StringIO
    StringIO
    PY3 = True
else:
    _long = long
    _basestring = basestring
    from StringIO import StringIO
    StringIO
    PY2 = True