Example #1
0
 def test_get_first_string_from_internet_when_an_error_appears(
         self, mock_urlopen):
     a = Mock()
     a.read.side_effect = ValueError('a')
     mock_urlopen.return_value = a
     self.assertRaises(ValueError, StringsExamples.get_first_string())
Example #2
0
 def test_get_first_string_from_internet(self, mock_urlopen):
     a = Mock()
     a.read.side_effect = ["hello good bye"]
     mock_urlopen.return_value = a
     assert StringsExamples.get_first_string() == "hello"