@@ -16,12 +16,14 @@ py32 = py3k and sys.version_info.minor == 2 | |||||
if py3k: | if py3k: | ||||
bytes = bytes | bytes = bytes | ||||
str = str | str = str | ||||
range = xrange | |||||
maxsize = sys.maxsize | maxsize = sys.maxsize | ||||
import html.entities as htmlentities | import html.entities as htmlentities | ||||
else: | else: | ||||
bytes = str | bytes = str | ||||
str = unicode | str = unicode | ||||
range = range | |||||
maxsize = sys.maxint | maxsize = sys.maxint | ||||
import htmlentitydefs as htmlentities | import htmlentitydefs as htmlentities | ||||
@@ -26,7 +26,7 @@ import re | |||||
from . import HTMLEntity, Node, Text | from . import HTMLEntity, Node, Text | ||||
from .extras import Parameter | from .extras import Parameter | ||||
from ..compat import str | |||||
from ..compat import range, str | |||||
from ..utils import parse_anything | from ..utils import parse_anything | ||||
__all__ = ["Template"] | __all__ = ["Template"] | ||||
@@ -25,7 +25,7 @@ from math import log | |||||
import re | import re | ||||
from . import contexts, tokens | from . import contexts, tokens | ||||
from ..compat import htmlentities | |||||
from ..compat import htmlentities, range | |||||
from ..definitions import (get_html_tag, is_parsable, is_single, | from ..definitions import (get_html_tag, is_parsable, is_single, | ||||
is_single_only, is_scheme) | is_single_only, is_scheme) | ||||
@@ -23,6 +23,7 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
from unittest import TestCase | from unittest import TestCase | ||||
from mwparserfromhell.compat import range | |||||
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | ||||
Tag, Template, Text, Wikilink) | Tag, Template, Text, Wikilink) | ||||
from mwparserfromhell.nodes.extras import Attribute, Parameter | from mwparserfromhell.nodes.extras import Attribute, Parameter | ||||
@@ -9,12 +9,10 @@ the main library. | |||||
from mwparserfromhell.compat import py3k | from mwparserfromhell.compat import py3k | ||||
if py3k: | if py3k: | ||||
range = range | |||||
from io import StringIO | from io import StringIO | ||||
from urllib.parse import urlencode | from urllib.parse import urlencode | ||||
from urllib.request import urlopen | from urllib.request import urlopen | ||||
else: | else: | ||||
range = xrange | |||||
from StringIO import StringIO | from StringIO import StringIO | ||||
from urllib import urlencode, urlopen | from urllib import urlencode, urlopen |
@@ -24,11 +24,11 @@ from __future__ import unicode_literals | |||||
import unittest | import unittest | ||||
from mwparserfromhell import parser | from mwparserfromhell import parser | ||||
from mwparserfromhell.compat import range | |||||
from mwparserfromhell.nodes import Tag, Template, Text, Wikilink | from mwparserfromhell.nodes import Tag, Template, Text, Wikilink | ||||
from mwparserfromhell.nodes.extras import Parameter | from mwparserfromhell.nodes.extras import Parameter | ||||
from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext | from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext | ||||
from .compat import range | |||||
class TestParser(TreeEqualityTestCase): | class TestParser(TreeEqualityTestCase): | ||||
"""Tests for the Parser class itself, which tokenizes and builds nodes.""" | """Tests for the Parser class itself, which tokenizes and builds nodes.""" | ||||
@@ -23,11 +23,9 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | import unittest | ||||
from mwparserfromhell.compat import py3k | |||||
from mwparserfromhell.compat import py3k, range | |||||
from mwparserfromhell.smart_list import SmartList, _ListProxy | from mwparserfromhell.smart_list import SmartList, _ListProxy | ||||
from .compat import range | |||||
class TestSmartList(unittest.TestCase): | class TestSmartList(unittest.TestCase): | ||||
"""Test cases for the SmartList class and its child, _ListProxy.""" | """Test cases for the SmartList class and its child, _ListProxy.""" | ||||
@@ -25,11 +25,9 @@ from sys import getdefaultencoding | |||||
from types import GeneratorType | from types import GeneratorType | ||||
import unittest | import unittest | ||||
from mwparserfromhell.compat import bytes, py3k, py32, str | |||||
from mwparserfromhell.compat import bytes, py3k, py32, range, str | |||||
from mwparserfromhell.string_mixin import StringMixIn | from mwparserfromhell.string_mixin import StringMixIn | ||||
from .compat import range | |||||
class _FakeString(StringMixIn): | class _FakeString(StringMixIn): | ||||
def __init__(self, data): | def __init__(self, data): | ||||
self._data = data | self._data = data | ||||
@@ -26,12 +26,12 @@ import re | |||||
from types import GeneratorType | from types import GeneratorType | ||||
import unittest | import unittest | ||||
from mwparserfromhell.compat import py3k, str | |||||
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | ||||
Node, Tag, Template, Text, Wikilink) | Node, Tag, Template, Text, Wikilink) | ||||
from mwparserfromhell.smart_list import SmartList | from mwparserfromhell.smart_list import SmartList | ||||
from mwparserfromhell.wikicode import Wikicode | from mwparserfromhell.wikicode import Wikicode | ||||
from mwparserfromhell import parse | from mwparserfromhell import parse | ||||
from mwparserfromhell.compat import py3k, str | |||||
from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext | from ._test_tree_equality import TreeEqualityTestCase, wrap, wraptext | ||||