Skip to content

Commit

Permalink
tests: fix compatibility with Python 2.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilk committed May 14, 2015
1 parent 800f515 commit dae56db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
17 changes: 16 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from nose import SkipTest
from nose.tools import (
assert_equal,
assert_greater,
assert_not_equal,
assert_true,
)
Expand All @@ -48,13 +47,29 @@ def assert_is_instance(obj, cls):

try:
from nose.tools import assert_is_none
from nose.tools import assert_is_not_none
except ImportError:
# Python 2.6:
def assert_is_none(obj):
assert_true(
obj is None,
msg='{0!r} is not None'.format(obj)
)
def assert_is_not_none(obj):
assert_true(
obj is not None,
msg='{0!r} is not None'.format(obj)
)

try:
from nose.tools import assert_greater
except ImportError:
# Python 2.6:
def assert_greater(x, y):
assert_true(
x > y,
msg='{0!r} not greater than {1!r}'.format(x, y)
)

def assert_regexp_matches(regexp, text):
if isinstance(regexp, basestring):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import re
import xml.etree.cElementTree as etree

from nose.tools import (
from . common import (
assert_equal,
assert_is_instance,
assert_is_not_none,
Expand Down

0 comments on commit dae56db

Please sign in to comment.