Update the unittest import to grab unittest2 for 2.6

pull/14/head
Richard Harding 12 years ago
parent 84f6a079f9
commit 75b3151de9

@ -25,6 +25,7 @@ tests_require = [
if sys.version_info < (2, 7):
# Require argparse since it's not in the stdlib yet.
install_requires.append('argparse')
install_requires.append('unittest2')
setup(
name='breadability',

@ -13,12 +13,16 @@ TESTPATH = path.join(
TESTTPL = """
import os
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.readable import Article
class TestArticle(TestCase):
class TestArticle(unittest.TestCase):
\"\"\"Test the scoring and parsing of the Article\"\"\"
def setUp(self):

@ -1,10 +1,14 @@
import os
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.readable import Article
class TestAntipopeBlog(TestCase):
class TestAntipopeBlog(unittest.TestCase):
"""Test the scoring and parsing of the Blog Post"""
def setUp(self):

@ -1,13 +1,18 @@
import os
from operator import attrgetter
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.readable import Article
from breadability.readable import check_siblings
from breadability.readable import prep_article
class TestArticle(TestCase):
class TestArticle(unittest.TestCase):
"""Test the scoring and parsing of the Article"""
def setUp(self):

@ -1,11 +1,16 @@
from collections import defaultdict
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.document import OriginalDocument
from breadability.tests import load_snippet
class TestOriginalDocument(TestCase):
class TestOriginalDocument(unittest.TestCase):
"""Verify we can process html into a document to work off of."""

@ -1,7 +1,11 @@
from lxml.etree import tounicode
from lxml.html import document_fromstring
from lxml.html import fragment_fromstring
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.readable import Article
from breadability.readable import get_class_weight
@ -14,7 +18,7 @@ from breadability.tests import load_snippet
from breadability.tests import load_article
class TestReadableDocument(TestCase):
class TestReadableDocument(unittest.TestCase):
"""Verify we can process html into a document to work off of."""
def test_load_doc(self):
@ -70,7 +74,7 @@ class TestReadableDocument(TestCase):
self.assertEqual(doc._readable.get('class'), 'parsing-error')
class TestCleaning(TestCase):
class TestCleaning(unittest.TestCase):
"""Test out our cleaning processing we do."""
def test_unlikely_hits(self):
@ -141,7 +145,7 @@ class TestCleaning(TestCase):
self.assertTrue(is_bad_link(link))
class TestCandidateNodes(TestCase):
class TestCandidateNodes(unittest.TestCase):
"""Candidate nodes are scoring containers we use."""
def test_candidate_scores(self):
@ -173,7 +177,7 @@ class TestCandidateNodes(TestCase):
self.assertTrue(hasattr(doc, 'candidates'))
class TestClassWeights(TestCase):
class TestClassWeights(unittest.TestCase):
"""Certain ids and classes get us bonus points."""
def test_positive_class(self):
@ -197,7 +201,7 @@ class TestClassWeights(TestCase):
self.assertEqual(get_class_weight(node), -25)
class TestScoringNodes(TestCase):
class TestScoringNodes(unittest.TestCase):
"""We take out list of potential nodes and score them up."""
def test_we_get_candidates(self):
@ -249,7 +253,7 @@ class TestScoringNodes(TestCase):
self.assertEqual(pscore_400, pscore_50 + 3)
class TestLinkDensityScoring(TestCase):
class TestLinkDensityScoring(unittest.TestCase):
"""Link density will adjust out candidate scoresself."""
def test_link_density(self):
@ -263,7 +267,7 @@ class TestLinkDensityScoring(TestCase):
self.assertTrue(density >= 0.0 and density <= 1.0)
class TestSiblings(TestCase):
class TestSiblings(unittest.TestCase):
"""Siblings will be included if their content is related."""
def test_bad_siblings_not_counted(self):

@ -2,7 +2,11 @@ import re
from lxml.html import document_fromstring
from lxml.html import fragment_fromstring
from operator import attrgetter
from unittest import TestCase
try:
# Python < 2.7
import unittest2 as unittest
except ImportError:
import unittest
from breadability.readable import Article
from breadability.scoring import check_node_attr
@ -14,7 +18,7 @@ from breadability.readable import is_unlikely_node
from breadability.tests import load_snippet
class TestCheckNodeAttr(TestCase):
class TestCheckNodeAttr(unittest.TestCase):
"""Verify a node has a class/id in the given set.
The idea is that we have sets of known good/bad ids and classes and need
@ -52,7 +56,7 @@ class TestCheckNodeAttr(TestCase):
self.assertFalse(check_node_attr(test_node, 'id', test_re))
class TestLinkDensity(TestCase):
class TestLinkDensity(unittest.TestCase):
"""Verify we calc our link density correctly."""
def test_empty_node(self):
@ -73,7 +77,7 @@ class TestLinkDensity(TestCase):
places=3)
class TestClassWeight(TestCase):
class TestClassWeight(unittest.TestCase):
"""Verify we score nodes correctly based on their class/id attributes."""
def test_no_matches_zero(self):
@ -125,7 +129,7 @@ class TestClassWeight(TestCase):
self.assertEqual(get_class_weight(node), 25)
class TestUnlikelyNode(TestCase):
class TestUnlikelyNode(unittest.TestCase):
"""is_unlikely_node should help verify our node is good/bad."""
def test_body_is_always_likely(self):
@ -161,7 +165,7 @@ class TestUnlikelyNode(TestCase):
self.assertFalse(is_unlikely_node(node))
class TestScoredNode(TestCase):
class TestScoredNode(unittest.TestCase):
"""ScoredNodes constructed have initial content_scores, etc."""
def test_hash_id(self):
@ -209,7 +213,7 @@ class TestScoredNode(TestCase):
self.assertEqual(snode.content_score, -3)
class TestScoreCandidates(TestCase):
class TestScoreCandidates(unittest.TestCase):
"""The grand daddy of tests to make sure our scoring works
Now scoring details will change over time, so the most important thing is

Loading…
Cancel
Save