Exemple #1
0
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')
Exemple #2
0
def test_strip(monkeypatch):
    monkeypatch.setattr(urlnorm, 'norm',
                        MagicMock(return_value=('   so much whitespace   ')))

    assert treat_url('http://foo.bar.com/') == 'so much whitespace'
Exemple #3
0
def test_sanity(url, expected):
    assert treat_url(url) == expected