diff --git a/src/tests/__init__.py b/src/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/tests/samples/si-game.sample.html b/src/tests/samples/si-game.sample.html new file mode 100644 index 0000000..fab4f4f --- /dev/null +++ b/src/tests/samples/si-game.sample.html @@ -0,0 +1,762 @@ + + + + + + Detroit Tigers vs. Kansas City Royals - Preview - April 16, 2012 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +
+
    +
  • + + + +
    Get the Wildcats Championship Package
    +
    Get the Wildcats Championship Package
    + + + + + +
  • +
  • +
  • +
  • + + + + +
    Get MLB 2K 12 FREE
    +
    Get MLB 2K 12 FREE
    + + + +
  • +
+
+
+
+ + + +
+
SI.com Home +
+ +
+
+ + + +
+ +
+ + + + +
+
+ +
+
+ + + +
+ + +
+ +
+ + +
+
+ +
+ + + + + +
+
+
+
  + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 123456789RHE
TIGERS            
ROYALS            
+
+ +
+
+ + + +
+ + + + + + +
PREVIEWMATCHUPFAN COMMENTS
+
+ + + +
+
+
+ + +

Tigers-Royals Preview

+

+ + Justin Verlander + has pitched well in each of his first two starts, though he doesn't have a win to show for those efforts. + +

+

+ He hasn't had much trouble earning victories against the + Kansas City Royals + . + +

+

+ Verlander looks to continue his mastery of the Royals when the + Detroit Tigers + visit Kauffman Stadium in the opener of a three-game series Monday night. + +

+

+ The reigning AL + Cy Young + winner and MVP had a 2-0 lead through eight innings in both of his outings, but the Tigers weren't able to hold the lead. + +

+

Verlander (0-1, 2.20 ERA) allowed two hits before running into trouble in the ninth against Tampa Bay on Wednesday, getting + charged with four runs in 8 1-3 innings of a 4-2 defeat. +

"Once a couple guys got on, really the first time I've cranked it up like that - and lost a little bit of my consistency that + I'd had all day," Verlander said. "It's inexcusable. This loss rests solely on my shoulders." +

The right-hander did his part in his opening-day start against Boston on April 5, allowing two hits before the bullpen faltered. + Detroit ended up winning 3-2 with a run in the bottom of the ninth, though Verlander didn't earn a decision. +

+

That hasn't been the case in his last four starts against the Royals, winning each with a 1.82 ERA. Verlander is 13-2 with + a 2.40 ERA in 19 career starts versus Kansas City, and another win will give him more victories than he has against any other + team. He's also beaten Cleveland 13 times. +

+

Verlander is 8-2 with a 1.82 ERA lifetime at Kauffman Stadium, where the Royals (3-6) were swept in a three-game series against + the Indians with Sunday's 13-7 loss. +

+

+ + Billy Butler + , who is 14 for 39 (.359) with two homers off Verlander, had an RBI single and is hitting .364 with four doubles and a homer + during a five-game hitting streak. + +

+

+ Royals pitchers allowed seven home runs, 17 extra-base hits and 32 runs in the series, and manager + Ned Yost + turned to outfielder + Mitch Maier + in the ninth to pitched a scoreless inning Sunday. + +

"Let's hope it doesn't happen again," Maier said. "I don't like to be put in that situation, but we needed an inning." +

+ Kansas City will look to bounce back with the help of another solid outing from + Danny Duffy + (1-0, 0.00), who allowed one hit and struck out eight in six innings of a 3-0 win over Oakland on Tuesday. + +

+

The left-hander will be seeking his first win against Detroit after going 0-2 with a 5.63 ERA in three starts versus the Tigers + as a rookie. +

+

+ + Gerald Laird + was a triple short of the cycle and helped the Tigers (6-3) salvage the finale of a three-game series with a 5-2 victory over + Chicago on Sunday. + +

+

+ + Rick Porcello + allowed one run in 7 2-3 innings to give Detroit's starting rotation its first victory. + +

"All the other starters have pitched well," Porcello said. "It's just the way it's happened so far." +

Verlander allowed three runs in seven innings of a 4-3 win over the Royals on Aug. 6, beating Duffy, who gave up three runs + over five. +

+ +

+ © 2011 STATS LLC STATS, Inc + +

+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ + + +
+ +
+
+
+
+
SI.com
+
Hot Topics: Peter King: MMQB NHL Playoffs Bobby Petrino Bobby Valentine Roger Clemens MLB Power Rankings Jackie Robinson
+
+
+ +
+
+ + Turner - SI Digital + +
Terms under which this service is provided to you. Read our privacy guidelines, your California privacy rights, and ad choices. +
+
+
SI CoverRead All ArticlesBuy Cover Reprint +
+
+
+ + + + +
+
+
+ + + + + + + +
+
+ + + + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/tests/test_article_only.py b/src/tests/test_article_only.py new file mode 100644 index 0000000..a45cba5 --- /dev/null +++ b/src/tests/test_article_only.py @@ -0,0 +1,39 @@ +import os +import unittest + +from readability import Document + + +SAMPLES = os.path.join(os.path.dirname(__file__), 'samples') + + +def load_sample(filename): + """Helper to get the content out of the sample files""" + return open(os.path.join(SAMPLES, filename)).read() + + +class TestArticleOnly(unittest.TestCase): + """The option to not get back a full html doc should work + + Given a full html document, the call can request just divs of processed + content. In this way the developer can then wrap the article however they + want in their own view or application. + + """ + + def test_si_sample(self): + """Using the si sample, load article with only opening body element""" + sample = load_sample('si-game.sample.html') + doc = Document( + sample, + url='http://sportsillustrated.cnn.com/baseball/mlb/gameflash/2012/04/16/40630_preview.html') + res = doc.summary() + self.assertEqual('