def test_urlnorm_error(monkeypatch): monkeypatch.setattr(urlnorm, 'norm', MagicMock(side_effect=urlnorm.InvalidUrl)) with pytest.raises(urlnorm.InvalidUrl): treat_url('dummy url') # pylint: disable=no-member urlnorm.norm.assert_called_once_with('dummy url')
def test_strip(monkeypatch): monkeypatch.setattr(urlnorm, 'norm', MagicMock(return_value=(' so much whitespace '))) assert treat_url('http://foo.bar.com/') == 'so much whitespace'
def test_sanity(url, expected): assert treat_url(url) == expected