Merge pull request #21 from miso-belica/upstream-sync
Synchronize with miso-belica/readability.py forkpull/23/head
commit
6d8a76a2b9
@ -1,3 +1,4 @@
|
||||
Rick Harding (original author)
|
||||
Michal Belica (current maintainer)
|
||||
nhnifong
|
||||
Craig Maloney
|
||||
Mišo Belica
|
||||
|
@ -1,4 +0,0 @@
|
||||
Rick Harding
|
||||
nhnifong
|
||||
Craig Maloney
|
||||
Mišo Belica
|
@ -1,3 +1,4 @@
|
||||
include README.rst
|
||||
include CHANGELOG.rst
|
||||
include LICENSE.rst
|
||||
include AUTHORS.txt
|
||||
|
@ -1,8 +1,9 @@
|
||||
charade
|
||||
coverage
|
||||
docopt>=0.6.1,<0.7
|
||||
charade
|
||||
lxml
|
||||
nose
|
||||
|
||||
nose-selecttests
|
||||
pep8
|
||||
pylint
|
||||
coverage
|
||||
nose
|
||||
pep8
|
||||
|
@ -0,0 +1,7 @@
|
||||
[nosetests]
|
||||
with-coverage=1
|
||||
cover-package=breadability
|
||||
cover-erase=1
|
||||
|
||||
[wheel]
|
||||
universal=1
|
@ -1,35 +0,0 @@
|
||||
# -*- coding: utf8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import atexit
|
||||
import nose
|
||||
|
||||
from os.path import dirname, abspath
|
||||
|
||||
|
||||
DEFAULT_PARAMS = [
|
||||
"nosetests",
|
||||
"--with-coverage",
|
||||
"--cover-package=breadability",
|
||||
"--cover-erase",
|
||||
]
|
||||
|
||||
|
||||
@atexit.register
|
||||
def exit_function(msg="Shutting down"):
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
|
||||
def run(argv=[]):
|
||||
sys.exitfunc = exit_function
|
||||
|
||||
nose.run(
|
||||
argv=DEFAULT_PARAMS + argv,
|
||||
defaultTest=abspath(dirname(__file__)),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
run(sys.argv[1:])
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,39 @@
|
||||
# -*- 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):
|
||||
"""Load up the article for us"""
|
||||
article_path = join(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")
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.document = None
|
||||
|
||||
def test_parses(self):
|
||||
"""Verify we can parse the document."""
|
||||
self.assertIn('id="readabilityBody"', self.document.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)
|
@ -1,31 +1,33 @@
|
||||
import os
|
||||
try:
|
||||
# Python < 2.7
|
||||
import unittest2 as unittest
|
||||
except ImportError:
|
||||
import unittest
|
||||
# -*- 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 Blog Post"""
|
||||
"""
|
||||
Test the scoring and parsing of the article from URL below:
|
||||
http://sweetshark.livejournal.com/11564.html
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""Load up the article for us"""
|
||||
article_path = os.path.join(os.path.dirname(__file__), 'article.html')
|
||||
self.article = open(article_path).read()
|
||||
article_path = join(dirname(__file__), "article.html")
|
||||
with open(article_path, "rb") as file:
|
||||
self.document = Article(file.read(), "http://sweetshark.livejournal.com/11564.html")
|
||||
|
||||
def tearDown(self):
|
||||
"""Drop the article"""
|
||||
self.article = None
|
||||
self.document = None
|
||||
|
||||
def test_parses(self):
|
||||
"""Verify we can parse the document."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('id="readabilityBody"' in doc.readable)
|
||||
self.assertIn('id="readabilityBody"', self.document.readable)
|
||||
|
||||
def test_content_after_video(self):
|
||||
"""The div with the comments should be removed."""
|
||||
doc = Article(self.article)
|
||||
self.assertTrue('Stay hungry, Stay foolish' in doc.readable)
|
||||
self.assertIn('Stay hungry, Stay foolish', self.document.readable)
|
||||
|
Loading…
Reference in New Issue