def test_fetch_google(self):
        with delayed_request('http://google.com').open() as istr:
            istr = iterator_to_file(iter(istr))
            all_content = content = istr.read(50)
            while len(content) == 50:
                content = istr.read(50)
                all_content += content
        self.assertTrue(all_content.endswith('</body></html>'))

        with delayed_request('http://google.com').open() as istr:
            istr = iterator_to_file(iter(istr))
            all_content_at_once = istr.read()
        self.assertTrue(all_content_at_once.endswith('</body></html>'))
Example #2
0
    def test_fetch_google(self):
        with delayed_request('http://google.com').open() as istr:
            istr = iterator_to_file(iter(istr))
            all_content = content = istr.read(50)
            while len(content) == 50:
                content = istr.read(50)
                all_content += content
        self.assertTrue(all_content.endswith('</body></html>'))

        with delayed_request('http://google.com').open() as istr:
            istr = iterator_to_file(iter(istr))
            all_content_at_once = istr.read()
        self.assertTrue(all_content_at_once.endswith('</body></html>'))
Example #3
0
 def test_json(self):
     s = delayed_request('http://google.com', param=dict(test='test'))
     self.assertEqual('"{\\"param\\": {\\"test\\": \\"test\\"}}"',
                      json.dumps(s, cls=CustomJSONEncoder))
     with mock.patch.object(__builtin__, 'repr', return_value=None) as test:
         CustomJSONEncoder().default('Test')
     test.assert_called_once_with('Test')
 def test_json(self):
     s = delayed_request('http://google.com', param=dict(test='test'))
     self.assertEqual(
         '"{\\"param\\": {\\"test\\": \\"test\\"}}"',
         json.dumps(s, cls=CustomJSONEncoder)
     )
     with mock.patch.object(__builtin__, 'repr',
                            return_value=None) as test:
         CustomJSONEncoder().default('Test')
     test.assert_called_once_with('Test')
 def test_pickle(self):
     s = delayed_request('http://google.com')
     json.dumps(repr(s))
     pickle.dumps(s)
Example #6
0
 def test_pickle(self):
     s = delayed_request('http://google.com')
     json.dumps(repr(s))
     pickle.dumps(s)