def fake_urlopen(self, url):
        if 'example' in url:
            response = StringIO('')
            return addinfourl(response, {'X-Pingback': '/xmlrpc.php',
                                         'Content-Type':
                                         'text/html; charset=utf-8'}, url)
        elif 'localhost' in url:
            response = StringIO(
                '<link rel="pingback" href="/xmlrpc/">')
            return addinfourl(response, {'Content-Type':
                                         'application/xhtml+xml'}, url)
        elif 'google' in url:
            response = StringIO('PNG CONTENT')
            return addinfourl(response, {'content-type': 'image/png'}, url)
        elif 'error' in url:
            raise URLError('Invalid ressource')
Initialize the MockScanner.
dataset/ETHPy150Open Fantomas42/django-blog-zinnia/zinnia/tests/test_ping.py/ExternalUrlsPingerTestCase.fake_urlopen--crossover with--dataset/ETHPy150Open home-assistant/home-assistant/tests/config/custom_components/device_tracker/test.py/MockScanner.__init__