Merge pull request #372 from untitaker/test-open-graphical-browser

Add tests for open_graphical_browser
This commit is contained in:
Markus Unterwaditzer 2016-03-10 12:13:00 +01:00
commit 55914bd575

View file

@ -79,3 +79,17 @@ def test_request_ssl_fingerprints(httpsserver, fingerprint):
utils.http.request('GET', httpsserver.url, verify=False,
verify_fingerprint=''.join(reversed(fingerprint)))
assert 'Fingerprints did not match' in str(excinfo.value)
def test_open_graphical_browser(monkeypatch):
import webbrowser
# Just assert that this internal attribute still exists,is some sort of
# collection and non-empty
assert len(webbrowser._tryorder)
monkeypatch.setattr('webbrowser._tryorder', [])
with pytest.raises(RuntimeError) as excinfo:
utils.open_graphical_browser('http://example.com')
assert 'No graphical browser found' in str(excinfo.value)