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
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', )]
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
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)
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',)]