File: compat.py

package info (click to toggle)
webtest 1.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 592 kB
  • sloc: python: 3,562; makefile: 42
file content (28 lines) | stat: -rw-r--r-- 503 bytes parent folder | download
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
# -*- coding: utf-8 -*-
import sys

try:
    # py < 2.7
    import unittest2 as unittest
except ImportError:
    import unittest

try:
    unicode()
except NameError:
    u = str
    b = bytes
else:
    def b(value):
        return str(value)
    def u(value):
        if isinstance(value, unicode):
            return value
        return unicode(value, 'utf-8')


if sys.version_info[:1] < (2, 6):
    def assertIn(self, x, y, c=None):
        assert x in y

    unittest.TestCase.assertIn = assertIn