コード例 #1
0
def extract_with_monkeypatched_logging(monkeypatch, excluded=[]):
    logger = FakeLogger('wex.entrypoints')
    monkeypatch.setattr('logging.getLogger', logger.getLogger)
    extractor = extractor_from_entry_points()
    readable = resource_stream(__name__, 'fixtures/robots_txt')
    for value in Response.values_from_readable(extractor, readable):
        pass
    return logger
コード例 #2
0
ファイル: test_response.py プロジェクト: ortodesign/wextracto
def test_extract_from_readable():
    readable = BytesIO(b'FTP/1.0 200 OK\r\n\r\nhello')

    def extract(src):
        yield (src.read(), )

    values = list(Response.values_from_readable(extract, readable))
    assert values == [(b'hello', )]
コード例 #3
0
def test_extractor_from_entry_points_hostname_suffix_excluded():
    import testme
    extractor = extractor_from_entry_points()
    readable = resource_stream(__name__, 'fixtures/robots_txt')
    for value in Response.values_from_readable(extractor, readable):
        pass
    hostname = 'www.foo.com'
    assert list(extractor.extractors.keys()) == [hostname]
    extractors = set(extractor.extractors[hostname].extractors)
    assert testme.example_with_hostname_suffix not in extractors
    assert testme.example in extractors
コード例 #4
0
def test_extractor_from_entry_points():
    import testme
    extract = extractor_from_entry_points()
    readable = resource_stream(__name__, 'fixtures/get_this_that')
    for value in Response.values_from_readable(extract, readable):
        pass
    hostname = 'httpbin.org'
    assert list(extract.extractors.keys()) == [hostname]
    extractors = set(extract.extractors[hostname].extractors)
    expected = set([testme.example, testme.example_with_hostname_suffix])
    assert expected.issubset(extractors)
コード例 #5
0
ファイル: test_response.py プロジェクト: eBay/wextracto
def test_extract_from_readable():
    readable = BytesIO(b'FTP/1.0 200 OK\r\n\r\nhello')
    def extract(src):
        yield (src.read(),)
    values = list(Response.values_from_readable(extract, readable))
    assert values == [(b'hello',)]