Tests migrated into pytest style
parent
48acf389b1
commit
aa83825334
@ -1,42 +1,45 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
"""Test the scoring and parsing of the Blog Post"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from breadability.readable import Article
|
||||
from ...compat import unittest
|
||||
import pytest
|
||||
|
||||
from breadability.readable import Article
|
||||
|
||||
class TestAntipopeBlog(unittest.TestCase):
|
||||
"""Test the scoring and parsing of the Blog Post"""
|
||||
|
||||
def setUp(self):
|
||||
@pytest.fixture(scope="module")
|
||||
def article():
|
||||
"""Load up the article for us"""
|
||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
||||
self.article = open(article_path).read()
|
||||
with open(article_path) as file:
|
||||
return file.read()
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.article = None
|
||||
|
||||
def test_parses(self):
|
||||
def test_parses(article):
|
||||
"""Verify we can parse the document."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('id="readabilityBody"' in doc.readable)
|
||||
doc = Article(article)
|
||||
|
||||
def test_comments_cleaned(self):
|
||||
assert 'id="readabilityBody"' in doc.readable
|
||||
|
||||
|
||||
def test_comments_cleaned(article):
|
||||
"""The div with the comments should be removed."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('class="comments"' not in doc.readable)
|
||||
doc = Article(article)
|
||||
|
||||
assert 'class="comments"' not in doc.readable
|
||||
|
||||
def test_beta_removed(self):
|
||||
|
||||
def test_beta_removed(article):
|
||||
"""The id=beta element should be removed
|
||||
|
||||
It's link heavy and causing a lot of garbage content. This should be
|
||||
removed.
|
||||
|
||||
"""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('id="beta"' not in doc.readable)
|
||||
doc = Article(article)
|
||||
|
||||
assert 'id="beta"' not in doc.readable
|
||||
|
@ -1,33 +1,34 @@
|
||||
import os
|
||||
try:
|
||||
# Python < 2.7
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from breadability.readable import Article
|
||||
"""Test the scoring and parsing of the Blog Post"""
|
||||
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
class TestBusinessInsiderArticle(unittest.TestCase):
|
||||
"""Test the scoring and parsing of the Blog Post"""
|
||||
import os
|
||||
|
||||
def setUp(self):
|
||||
import pytest
|
||||
|
||||
from breadability.readable import Article
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def article():
|
||||
"""Load up the article for us"""
|
||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
||||
self.article = open(article_path).read()
|
||||
with open(article_path) as file:
|
||||
return file.read()
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.article = None
|
||||
|
||||
def test_parses(self):
|
||||
def test_parses(article):
|
||||
"""Verify we can parse the document."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('id="readabilityBody"' in doc.readable)
|
||||
doc = Article(article)
|
||||
|
||||
assert 'id="readabilityBody"' in doc.readable
|
||||
|
||||
def test_images_preserved(self):
|
||||
|
||||
def test_images_preserved(article):
|
||||
"""The div with the comments should be removed."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('bharath-kumar-a-co-founder-at-pugmarksme-suggests-working-on-a-sunday-late-night.jpg' in doc.readable)
|
||||
self.assertTrue('bryan-guido-hassin-a-university-professor-and-startup-junkie-uses-airplane-days.jpg' in doc.readable)
|
||||
doc = Article(article)
|
||||
|
||||
assert 'bharath-kumar-a-co-founder-at-pugmarksme-suggests-working-on-a-sunday-late-night.jpg' in doc.readable
|
||||
assert 'bryan-guido-hassin-a-university-professor-and-startup-junkie-uses-airplane-days.jpg' in doc.readable
|
||||
|
@ -1,39 +1,33 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
|
||||
from os.path import join, dirname
|
||||
from breadability.readable import Article
|
||||
from ...compat import unittest
|
||||
|
||||
|
||||
class TestArticle(unittest.TestCase):
|
||||
"""
|
||||
Test the scoring and parsing of the article from URL below:
|
||||
http://www.businessinsider.com/tech-ceos-favorite-productivity-hacks-2013-8
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from breadability.readable import Article
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def article():
|
||||
"""Load up the article for us"""
|
||||
article_path = join(dirname(__file__), "article.html")
|
||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
||||
with open(article_path, "rb") as file:
|
||||
self.document = Article(file.read(), "http://www.businessinsider.com/tech-ceos-favorite-productivity-hacks-2013-8")
|
||||
return Article(file.read(), "http://www.businessinsider.com/tech-ceos-favorite-productivity-hacks-2013-8")
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.document = None
|
||||
|
||||
def test_parses(self):
|
||||
def test_parses(article):
|
||||
"""Verify we can parse the document."""
|
||||
self.assertIn('id="readabilityBody"', self.document.readable)
|
||||
assert 'id="readabilityBody"' in article.readable
|
||||
|
||||
def test_images_preserved(self):
|
||||
"""The div with the comments should be removed."""
|
||||
images = [
|
||||
'bharath-kumar-a-co-founder-at-pugmarksme-suggests-working-on-a-sunday-late-night.jpg',
|
||||
'bryan-guido-hassin-a-university-professor-and-startup-junkie-uses-airplane-days.jpg',
|
||||
]
|
||||
|
||||
for image in images:
|
||||
self.assertIn(image, self.document.readable, image)
|
||||
def test_images_preserved(article):
|
||||
"""The div with the comments should be removed."""
|
||||
assert 'bharath-kumar-a-co-founder-at-pugmarksme-suggests-working-on-a-sunday-late-night.jpg' in article.readable
|
||||
assert 'bryan-guido-hassin-a-university-professor-and-startup-junkie-uses-airplane-days.jpg' in article.readable
|
||||
|
@ -1,33 +1,32 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division, print_function, unicode_literals
|
||||
|
||||
from os.path import join, dirname
|
||||
from breadability.readable import Article
|
||||
from ...compat import unittest
|
||||
|
||||
|
||||
class TestSweetsharkBlog(unittest.TestCase):
|
||||
"""
|
||||
Test the scoring and parsing of the article from URL below:
|
||||
http://sweetshark.livejournal.com/11564.html
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from breadability.readable import Article
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def article():
|
||||
"""Load up the article for us"""
|
||||
article_path = join(dirname(__file__), "article.html")
|
||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
||||
with open(article_path, "rb") as file:
|
||||
self.document = Article(file.read(), "http://sweetshark.livejournal.com/11564.html")
|
||||
return Article(file.read(), "http://sweetshark.livejournal.com/11564.html")
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.document = None
|
||||
|
||||
def test_parses(self):
|
||||
def test_parses(article):
|
||||
"""Verify we can parse the document."""
|
||||
self.assertIn('id="readabilityBody"', self.document.readable)
|
||||
assert 'id="readabilityBody"' in article.readable
|
||||
|
||||
|
||||
def test_content_after_video(self):
|
||||
def test_content_after_video(article):
|
||||
"""The div with the comments should be removed."""
|
||||
self.assertIn('Stay hungry, Stay foolish', self.document.readable)
|
||||
assert 'Stay hungry, Stay foolish' in article.readable
|
||||
|
Loading…
Reference in New Issue