@@ -0,0 +1,23 @@ | |||||
# -*- coding: UTF-8 -*- | |||||
""" | |||||
Discover tests using ``unittest2`. | |||||
It appears the default distutils test suite doesn't play nice with | |||||
``setUpClass`` thereby making some tests fail. Using ``unittest2`` | |||||
to load tests seems to work around that issue. | |||||
http://stackoverflow.com/a/17004409/753501 | |||||
""" | |||||
# Standard: | |||||
import os | |||||
# External: | |||||
import unittest2 | |||||
def additional_tests(): | |||||
return unittest2.defaultTestLoader.discover(os.path.dirname(__file__)) |
@@ -42,7 +42,8 @@ setup( | |||||
name = "mwparserfromhell", | name = "mwparserfromhell", | ||||
packages = find_packages(exclude=("tests",)), | packages = find_packages(exclude=("tests",)), | ||||
ext_modules = [tokenizer], | ext_modules = [tokenizer], | ||||
test_suite = "tests", | |||||
tests_require = ['unittest2'], | |||||
test_suite = "discover_tests", | |||||
version = __version__, | version = __version__, | ||||
author = "Ben Kurtovic", | author = "Ben Kurtovic", | ||||
author_email = "ben.kurtovic@gmail.com", | author_email = "ben.kurtovic@gmail.com", | ||||
@@ -35,7 +35,7 @@ class _TestParseError(Exception): | |||||
class TokenizerTestCase(object): | class TokenizerTestCase(object): | ||||
"""A base test case for tokenizers, whose tests are loaded dynamically. | """A base test case for tokenizers, whose tests are loaded dynamically. | ||||
Subclassed along with unittest.TestCase to form TestPyTokenizer and | |||||
Subclassed along with unittest2.TestCase to form TestPyTokenizer and | |||||
TestCTokenizer. Tests are loaded dynamically from files in the 'tokenizer' | TestCTokenizer. Tests are loaded dynamically from files in the 'tokenizer' | ||||
directory. | directory. | ||||
""" | """ | ||||
@@ -121,7 +121,7 @@ class TokenizerTestCase(object): | |||||
if len(sys.argv) > 2 and sys.argv[1] == "--use": | if len(sys.argv) > 2 and sys.argv[1] == "--use": | ||||
for name in sys.argv[2:]: | for name in sys.argv[2:]: | ||||
load_file(path.join(directory, name + extension)) | load_file(path.join(directory, name + extension)) | ||||
sys.argv = [sys.argv[0]] # So unittest doesn't try to load these | |||||
sys.argv = [sys.argv[0]] # So unittest2 doesn't try to load these | |||||
cls.skip_others = True | cls.skip_others = True | ||||
else: | else: | ||||
for filename in listdir(directory): | for filename in listdir(directory): | ||||
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
from unittest import TestCase | |||||
from unittest2 import TestCase | |||||
from mwparserfromhell.compat import range | from mwparserfromhell.compat import range | ||||
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | ||||
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Argument, Text | from mwparserfromhell.nodes import Argument, Text | ||||
@@ -99,4 +99,4 @@ class TestArgument(TreeEqualityTestCase): | |||||
self.assertIs(None, node2.default) | self.assertIs(None, node2.default) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Template | from mwparserfromhell.nodes import Template | ||||
@@ -86,4 +86,4 @@ class TestAttribute(TreeEqualityTestCase): | |||||
self.assertRaises(ValueError, setattr, node, pad, True) | self.assertRaises(ValueError, setattr, node, pad, True) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.nodes import (Argument, Comment, ExternalLink, Heading, | from mwparserfromhell.nodes import (Argument, Comment, ExternalLink, Heading, | ||||
HTMLEntity, Tag, Template, Text, Wikilink) | HTMLEntity, Tag, Template, Text, Wikilink) | ||||
@@ -417,4 +417,4 @@ class TestBuilder(TreeEqualityTestCase): | |||||
self.assertWikicodeEqual(valid, self.builder.build(test)) | self.assertWikicodeEqual(valid, self.builder.build(test)) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Comment | from mwparserfromhell.nodes import Comment | ||||
@@ -64,4 +64,4 @@ class TestComment(TreeEqualityTestCase): | |||||
self.assertEqual("barfoo", node.contents) | self.assertEqual("barfoo", node.contents) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
try: | try: | ||||
from mwparserfromhell.parser._tokenizer import CTokenizer | from mwparserfromhell.parser._tokenizer import CTokenizer | ||||
@@ -30,8 +30,8 @@ except ImportError: | |||||
from ._test_tokenizer import TokenizerTestCase | from ._test_tokenizer import TokenizerTestCase | ||||
@unittest.skipUnless(CTokenizer, "C tokenizer not available") | |||||
class TestCTokenizer(TokenizerTestCase, unittest.TestCase): | |||||
@unittest2.skipUnless(CTokenizer, "C tokenizer not available") | |||||
class TestCTokenizer(TokenizerTestCase, unittest2.TestCase): | |||||
"""Test cases for the C tokenizer.""" | """Test cases for the C tokenizer.""" | ||||
@classmethod | @classmethod | ||||
@@ -45,4 +45,4 @@ class TestCTokenizer(TokenizerTestCase, unittest.TestCase): | |||||
self.assertTrue(CTokenizer().USES_C) | self.assertTrue(CTokenizer().USES_C) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -22,14 +22,14 @@ | |||||
from __future__ import print_function, unicode_literals | from __future__ import print_function, unicode_literals | ||||
import json | import json | ||||
import unittest | |||||
import unittest2 | |||||
import mwparserfromhell | import mwparserfromhell | ||||
from mwparserfromhell.compat import py3k, str | from mwparserfromhell.compat import py3k, str | ||||
from .compat import StringIO, urlencode, urlopen | from .compat import StringIO, urlencode, urlopen | ||||
class TestDocs(unittest.TestCase): | |||||
class TestDocs(unittest2.TestCase): | |||||
"""Integration test cases for mwparserfromhell's documentation.""" | """Integration test cases for mwparserfromhell's documentation.""" | ||||
def assertPrint(self, input, output): | def assertPrint(self, input, output): | ||||
@@ -128,4 +128,4 @@ class TestDocs(unittest.TestCase): | |||||
self.assertEqual(expected, actual) | self.assertEqual(expected, actual) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import ExternalLink, Text | from mwparserfromhell.nodes import ExternalLink, Text | ||||
@@ -122,4 +122,4 @@ class TestExternalLink(TreeEqualityTestCase): | |||||
self.assertEqual("http://example.com/", str(node2)) | self.assertEqual("http://example.com/", str(node2)) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Heading, Text | from mwparserfromhell.nodes import Heading, Text | ||||
@@ -85,4 +85,4 @@ class TestHeading(TreeEqualityTestCase): | |||||
self.assertRaises(ValueError, setattr, node, "level", False) | self.assertRaises(ValueError, setattr, node, "level", False) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import HTMLEntity | from mwparserfromhell.nodes import HTMLEntity | ||||
@@ -165,4 +165,4 @@ class TestHTMLEntity(TreeEqualityTestCase): | |||||
self.assertEqual("\U0001F648", node4.normalize()) | self.assertEqual("\U0001F648", node4.normalize()) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Text | from mwparserfromhell.nodes import Text | ||||
@@ -72,4 +72,4 @@ class TestParameter(TreeEqualityTestCase): | |||||
self.assertFalse(node2.showkey) | self.assertFalse(node2.showkey) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell import parser | from mwparserfromhell import parser | ||||
from mwparserfromhell.compat import range | from mwparserfromhell.compat import range | ||||
@@ -86,4 +86,4 @@ class TestParser(TreeEqualityTestCase): | |||||
parser.use_c = restore | parser.use_c = restore | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,13 +21,13 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.parser.tokenizer import Tokenizer | from mwparserfromhell.parser.tokenizer import Tokenizer | ||||
from ._test_tokenizer import TokenizerTestCase | from ._test_tokenizer import TokenizerTestCase | ||||
class TestPyTokenizer(TokenizerTestCase, unittest.TestCase): | |||||
class TestPyTokenizer(TokenizerTestCase, unittest2.TestCase): | |||||
"""Test cases for the Python tokenizer.""" | """Test cases for the Python tokenizer.""" | ||||
@classmethod | @classmethod | ||||
@@ -41,4 +41,4 @@ class TestPyTokenizer(TokenizerTestCase, unittest.TestCase): | |||||
self.assertFalse(Tokenizer().USES_C) | self.assertFalse(Tokenizer().USES_C) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,12 +21,12 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import py3k, range | from mwparserfromhell.compat import py3k, range | ||||
from mwparserfromhell.smart_list import SmartList, _ListProxy | from mwparserfromhell.smart_list import SmartList, _ListProxy | ||||
class TestSmartList(unittest.TestCase): | |||||
class TestSmartList(unittest2.TestCase): | |||||
"""Test cases for the SmartList class and its child, _ListProxy.""" | """Test cases for the SmartList class and its child, _ListProxy.""" | ||||
def _test_get_set_del_item(self, builder): | def _test_get_set_del_item(self, builder): | ||||
@@ -387,4 +387,4 @@ class TestSmartList(unittest.TestCase): | |||||
self.assertEqual([4, 3, 2, 1.9, 1.8], child2) | self.assertEqual([4, 3, 2, 1.9, 1.8], child2) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -23,7 +23,7 @@ | |||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
from sys import getdefaultencoding | from sys import getdefaultencoding | ||||
from types import GeneratorType | from types import GeneratorType | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import bytes, py3k, py32, range, str | from mwparserfromhell.compat import bytes, py3k, py32, range, str | ||||
from mwparserfromhell.string_mixin import StringMixIn | from mwparserfromhell.string_mixin import StringMixIn | ||||
@@ -36,7 +36,7 @@ class _FakeString(StringMixIn): | |||||
return self._data | return self._data | ||||
class TestStringMixIn(unittest.TestCase): | |||||
class TestStringMixIn(unittest2.TestCase): | |||||
"""Test cases for the StringMixIn class.""" | """Test cases for the StringMixIn class.""" | ||||
def test_docs(self): | def test_docs(self): | ||||
@@ -432,4 +432,4 @@ class TestStringMixIn(unittest.TestCase): | |||||
self.assertEqual("000123", str12.zfill(6)) | self.assertEqual("000123", str12.zfill(6)) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Tag, Template, Text | from mwparserfromhell.nodes import Tag, Template, Text | ||||
@@ -305,4 +305,4 @@ class TestTag(TreeEqualityTestCase): | |||||
self.assertEqual('<div/>', node) | self.assertEqual('<div/>', node) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import HTMLEntity, Template, Text | from mwparserfromhell.nodes import HTMLEntity, Template, Text | ||||
@@ -428,4 +428,4 @@ class TestTemplate(TreeEqualityTestCase): | |||||
self.assertEqual("{{foo|a=b|c=d|e=f|a=|a=b}}", node26) | self.assertEqual("{{foo|a=b|c=d|e=f|a=|a=b}}", node26) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,12 +21,12 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Text | from mwparserfromhell.nodes import Text | ||||
class TestText(unittest.TestCase): | |||||
class TestText(unittest2.TestCase): | |||||
"""Test cases for the Text node.""" | """Test cases for the Text node.""" | ||||
def test_unicode(self): | def test_unicode(self): | ||||
@@ -71,4 +71,4 @@ class TestText(unittest.TestCase): | |||||
self.assertIsInstance(node.value, str) | self.assertIsInstance(node.value, str) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,12 +21,12 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import py3k | from mwparserfromhell.compat import py3k | ||||
from mwparserfromhell.parser import tokens | from mwparserfromhell.parser import tokens | ||||
class TestTokens(unittest.TestCase): | |||||
class TestTokens(unittest2.TestCase): | |||||
"""Test cases for the Token class and its subclasses.""" | """Test cases for the Token class and its subclasses.""" | ||||
def test_issubclass(self): | def test_issubclass(self): | ||||
@@ -105,4 +105,4 @@ class TestTokens(unittest.TestCase): | |||||
self.assertEqual(token, eval(repr(token), vars(tokens))) | self.assertEqual(token, eval(repr(token), vars(tokens))) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.nodes import Template, Text | from mwparserfromhell.nodes import Template, Text | ||||
from mwparserfromhell.utils import parse_anything | from mwparserfromhell.utils import parse_anything | ||||
@@ -59,4 +59,4 @@ class TestUtils(TreeEqualityTestCase): | |||||
self.assertRaises(ValueError, parse_anything, ["foo", [object]]) | self.assertRaises(ValueError, parse_anything, ["foo", [object]]) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -24,7 +24,7 @@ from __future__ import unicode_literals | |||||
from functools import partial | from functools import partial | ||||
import re | import re | ||||
from types import GeneratorType | from types import GeneratorType | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import py3k, str | from mwparserfromhell.compat import py3k, str | ||||
from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | from mwparserfromhell.nodes import (Argument, Comment, Heading, HTMLEntity, | ||||
@@ -432,4 +432,4 @@ class TestWikicode(TreeEqualityTestCase): | |||||
self.assertEqual(expected.expandtabs(4), code.get_tree()) | self.assertEqual(expected.expandtabs(4), code.get_tree()) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |
@@ -21,7 +21,7 @@ | |||||
# SOFTWARE. | # SOFTWARE. | ||||
from __future__ import unicode_literals | from __future__ import unicode_literals | ||||
import unittest | |||||
import unittest2 | |||||
from mwparserfromhell.compat import str | from mwparserfromhell.compat import str | ||||
from mwparserfromhell.nodes import Text, Wikilink | from mwparserfromhell.nodes import Text, Wikilink | ||||
@@ -99,4 +99,4 @@ class TestWikilink(TreeEqualityTestCase): | |||||
self.assertIs(None, node2.text) | self.assertIs(None, node2.text) | ||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
unittest.main(verbosity=2) | |||||
unittest2.main(verbosity=2) |