def test_href_detects_multiline(): """Ensure the hrefs are detected even if the text more than one line. Example: Cool sites for today: https://www.reddit.com/ http://digg.com/ (yes! it's still alive!) https://news.ycombinator.com/ Results: ( 'https://www.reddit.com/', 'http://digg.com/', 'https://news.ycombinator.com/', ) """ results = tuple( href.hrefs( """Cool sites for today: https://www.reddit.com/ http://digg.com/ (yes! it's still alive!) https://news.ycombinator.com/""", ) ) assert 'https://www.reddit.com/' in results assert 'http://digg.com/' in results assert 'https://news.ycombinator.com/' in results assert len(results) == 3
def test_hrefs_are_empty_if_not_present(): """Ensure there are no hrefs generated if none exist in the text. Example: is anybody there? Result: () """ results = tuple(href.hrefs('is anybody there?')) assert not results
def test_href_detects_mid_stream(): """Ensure hrefs within the body of the text are found. Example: I just discovered https://zombo.com today. Result: ('https://zombo.com',) """ results = tuple( href.hrefs('I just discovered https://zombo.com today.') ) assert 'https://zombo.com' in results assert len(results) == 1
def test_href_detects_at_text_start(): """Ensure hrefs at the beginning of a line of text are found. Example: http://example.com/some_page is not a great site. Result: ('http://example.com/some_page',) """ results = tuple( href.hrefs('http://example.com/some_page is not a great site.') ) assert 'http://example.com/some_page' in results assert len(results) == 1
def test_href_detects_end_of_text(): """Ensure hrefs at the end of a line are also detected. Example: Check if you're connected by hitting http://www.purple.com/. Results: ('http://www.purple.com/',) """ results = tuple( href.hrefs( "Check if you're connected by hitting http://www.purple.com/.", ) ) assert 'http://www.purple.com/' in results assert len(results) == 1
def test_href_detects_multiple_hrefs(): """Ensure multiple hrefs are detected if given. Example: Check out https://one.com, http://two.com, and https://three.com! Results: (https://one.com, http://two.com, https://three.com) """ results = tuple( href.hrefs( 'Check out https://one.com, http://two.com, and https://three.com!' ) ) assert 'https://one.com' in results assert 'http://two.com' in results assert 'https://three.com' in results assert len(results) == 3