def test_article_success_context_manager_mocked(self):
     with patch.object(Wikipedia, 'article') as mock_method:
         article = Definitions.article("Robot")        
         mock_method.assert_called_once_with("Robot")
 def test_article_success(self):
     article = Definitions.article("Robot")        
     self.assertIn("mechanical", article)
 def test_article_success_decorator_mocked(self, mock_method):
     article = Definitions.article("Robot")        
     mock_method.assert_called_once_with("Robot")
 def test_article_failure_decorator_mocked(self, mock_method):
     title = 'lksjdflksjdl'
     article = Definitions.article(title)
     mock_method.assertRaises(ParseError, article, "Your search for {} did not return any results.".format(title))
 def test_article_success_decorator_mocked(self, mock_method):
     article = Definitions.article("Robot")
     mock_method.assert_called_once_with("Robot")
#!/usr/bin/env python

import sys

from definitions import Definitions

title = sys.argv[1]

print Definitions.article(title).encode('utf-8')

#!/usr/bin/env python

import sys

from definitions import Definitions
from html2text import html2text

title = len(sys.argv) == 2 and sys.argv[1] or ""


definition = Definitions.article(title)
txt = html2text(definition)
print txt.encode('utf-8')

 def test_article_success(self):
     article = Definitions.article("Robot")
     self.assertIn("mechanical", article)
Exemple #9
0
#!/usr/bin/env python

import sys

from definitions import Definitions
from html2text import html2text

title = len(sys.argv) == 2 and sys.argv[1] or ""

definition = Definitions.article(title)
# txt = html2text(definition)
# print txt.encode('utf-8')
print definition

Exemple #10
0
 def test_article_success_context_manager_mocked(self):
     with patch.object(Wikipedia, 'article') as mock_method:
         article = Definitions.article("Robot")
         mock_method.assert_called_once_with("Robot")
 def test_article_contents_mocked(self, mock_method):
     mock_method.return_value = "A robot is mechanical"
     article = Definitions.article("Robot")
     self.assertIn("mechanical", article)
Exemple #12
0
#!/usr/bin/env python3
"""
Script to contact Wikipedia and get articles on a specified topic.
python define.py interesting_topic
"""

import sys

from definitions import Definitions

title = sys.argv[1]

print(Definitions.article(title).encode('utf-8'))
 def test_article_contents_mocked(self, mock_method):
     mock_method.return_value = "A robot is mechanical"
     article = Definitions.article("Robot")
     self.assertIn("mechanical", article)