Tests migrated into pytest style
parent
48acf389b1
commit
aa83825334
@ -1,42 +1,45 @@
|
|||||||
# -*- coding: utf8 -*-
|
# -*- coding: utf8 -*-
|
||||||
|
|
||||||
from __future__ import absolute_import
|
"""Test the scoring and parsing of the Blog Post"""
|
||||||
from __future__ import division, print_function, unicode_literals
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from breadability.readable import Article
|
import pytest
|
||||||
from ...compat import unittest
|
|
||||||
|
|
||||||
|
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"""
|
"""Load up the article for us"""
|
||||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
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."""
|
"""Verify we can parse the document."""
|
||||||
doc = Article(self.article)
|
doc = Article(article)
|
||||||
self.assertTrue('id="readabilityBody"' in doc.readable)
|
|
||||||
|
assert 'id="readabilityBody"' in doc.readable
|
||||||
|
|
||||||
def test_comments_cleaned(self):
|
|
||||||
|
def test_comments_cleaned(article):
|
||||||
"""The div with the comments should be removed."""
|
"""The div with the comments should be removed."""
|
||||||
doc = Article(self.article)
|
doc = Article(article)
|
||||||
self.assertTrue('class="comments"' not in doc.readable)
|
|
||||||
|
assert 'class="comments"' not in doc.readable
|
||||||
|
|
||||||
def test_beta_removed(self):
|
|
||||||
|
def test_beta_removed(article):
|
||||||
"""The id=beta element should be removed
|
"""The id=beta element should be removed
|
||||||
|
|
||||||
It's link heavy and causing a lot of garbage content. This should be
|
It's link heavy and causing a lot of garbage content. This should be
|
||||||
removed.
|
removed.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
doc = Article(self.article)
|
doc = Article(article)
|
||||||
self.assertTrue('id="beta"' not in doc.readable)
|
|
||||||
|
assert 'id="beta"' not in doc.readable
|
||||||
|
@ -1,33 +1,34 @@
|
|||||||
import os
|
# -*- coding: utf8 -*-
|
||||||
try:
|
|
||||||
# Python < 2.7
|
|
||||||
import unittest2 as unittest
|
|
||||||
except ImportError:
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
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):
|
import os
|
||||||
"""Test the scoring and parsing of the Blog Post"""
|
|
||||||
|
|
||||||
def setUp(self):
|
import pytest
|
||||||
|
|
||||||
|
from breadability.readable import Article
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def article():
|
||||||
"""Load up the article for us"""
|
"""Load up the article for us"""
|
||||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
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."""
|
"""Verify we can parse the document."""
|
||||||
doc = Article(self.article)
|
doc = Article(article)
|
||||||
self.assertTrue('id="readabilityBody"' in doc.readable)
|
|
||||||
|
assert 'id="readabilityBody"' in doc.readable
|
||||||
|
|
||||||
def test_images_preserved(self):
|
|
||||||
|
def test_images_preserved(article):
|
||||||
"""The div with the comments should be removed."""
|
"""The div with the comments should be removed."""
|
||||||
doc = Article(self.article)
|
doc = Article(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)
|
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 -*-
|
# -*- coding: utf8 -*-
|
||||||
|
|
||||||
from __future__ import absolute_import
|
"""
|
||||||
from __future__ import division, print_function, unicode_literals
|
Test the scoring and parsing of the article from URL below:
|
||||||
|
http://www.businessinsider.com/tech-ceos-favorite-productivity-hacks-2013-8
|
||||||
|
"""
|
||||||
|
|
||||||
from os.path import join, dirname
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
from breadability.readable import Article
|
|
||||||
from ...compat import unittest
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from breadability.readable import Article
|
||||||
|
|
||||||
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):
|
@pytest.fixture(scope="module")
|
||||||
|
def article():
|
||||||
"""Load up the article for us"""
|
"""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:
|
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."""
|
"""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:
|
def test_images_preserved(article):
|
||||||
self.assertIn(image, self.document.readable, image)
|
"""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 -*-
|
# -*- coding: utf8 -*-
|
||||||
|
|
||||||
from __future__ import absolute_import
|
"""
|
||||||
from __future__ import division, print_function, unicode_literals
|
Test the scoring and parsing of the article from URL below:
|
||||||
|
http://sweetshark.livejournal.com/11564.html
|
||||||
|
"""
|
||||||
|
|
||||||
from os.path import join, dirname
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
from breadability.readable import Article
|
|
||||||
from ...compat import unittest
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
class TestSweetsharkBlog(unittest.TestCase):
|
from breadability.readable import Article
|
||||||
"""
|
|
||||||
Test the scoring and parsing of the article from URL below:
|
|
||||||
http://sweetshark.livejournal.com/11564.html
|
|
||||||
"""
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def article():
|
||||||
"""Load up the article for us"""
|
"""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:
|
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."""
|
"""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."""
|
"""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