Patchwork D3469: tests: fix error case in test-url.py's doctest

login
register
mail settings
Submitter phabricator
Date May 8, 2018, 4:26 a.m.
Message ID <differential-rev-PHID-DREV-kj3le3nruir2evmuuud6-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31320/
State Superseded
Headers show

Comments

phabricator - May 8, 2018, 4:26 a.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This required some careful attention, so I wanted to split it out from
  the uninteresting bits that'll be in the next change.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3469

AFFECTED FILES
  tests/test-url.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-url.py b/tests/test-url.py
--- a/tests/test-url.py
+++ b/tests/test-url.py
@@ -236,7 +236,8 @@ 
 
 def test_url():
     """
-    >>> from mercurial.util import url
+    >>> from mercurial import error, pycompat
+    >>> from mercurial.util import forcebytestr, url
 
     This tests for edge cases in url.URL's parsing algorithm. Most of
     these aren't useful for documentation purposes, so they aren't
@@ -349,10 +350,11 @@ 
 
     Non-localhost file URL:
 
-    >>> u = url('file://mercurial-scm.org/foo')
-    Traceback (most recent call last):
-      File "<stdin>", line 1, in ?
-    Abort: file:// URLs can only refer to localhost
+    >>> try:
+    ...   u = url(b'file://mercurial-scm.org/foo')
+    ... except error.Abort as e:
+    ...   forcebytestr(e)
+    'file:// URLs can only refer to localhost'
 
     Empty URL: