Patchwork D3373: tests: port test-hg-parseurl.py to unittest

login
register
mail settings
Submitter phabricator
Date April 14, 2018, 3:13 p.m.
Message ID <differential-rev-PHID-DREV-y43ey5d7sznlpdcjxbqg-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31041/
State Superseded
Headers show

Comments

phabricator - April 14, 2018, 3:13 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-hg-parseurl.py
  tests/test-hg-parseurl.py.out

CHANGE DETAILS




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

Patch

diff --git a/tests/test-hg-parseurl.py.out b/tests/test-hg-parseurl.py.out
deleted file mode 100644
--- a/tests/test-hg-parseurl.py.out
+++ /dev/null
@@ -1,8 +0,0 @@ 
-http://example.com/no/anchor, branches: (None, [])
-http://example.com/an/anchor, branches: ('foo', [])
-http://example.com/no/anchor/branches, branches: (None, ['foo'])
-http://example.com/an/anchor/branches, branches: ('bar', ['foo'])
-http://example.com/an/anchor/branches-None, branches: ('foo', [])
-http://example.com/, branches: (None, [])
-http://example.com/, branches: (None, [])
-http://example.com/, branches: ('foo', [])
diff --git a/tests/test-hg-parseurl.py b/tests/test-hg-parseurl.py
--- a/tests/test-hg-parseurl.py
+++ b/tests/test-hg-parseurl.py
@@ -1,17 +1,34 @@ 
 from __future__ import absolute_import, print_function
 
+import unittest
+
 from mercurial import (
     hg,
 )
 
-def testparse(url, branch=[]):
-    print('%s, branches: %r' % hg.parseurl(url, branch))
+class ParseRequestTests(unittest.TestCase):
+    def testparse(self):
 
-testparse('http://example.com/no/anchor')
-testparse('http://example.com/an/anchor#foo')
-testparse('http://example.com/no/anchor/branches', branch=['foo'])
-testparse('http://example.com/an/anchor/branches#bar', branch=['foo'])
-testparse('http://example.com/an/anchor/branches-None#foo', branch=None)
-testparse('http://example.com/')
-testparse('http://example.com')
-testparse('http://example.com#foo')
+        self.assertEqual(hg.parseurl('http://example.com/no/anchor'),
+                         ('http://example.com/no/anchor', (None, [])))
+        self.assertEqual(hg.parseurl('http://example.com/an/anchor#foo'),
+                         ('http://example.com/an/anchor', ('foo', [])))
+        self.assertEqual(
+            hg.parseurl('http://example.com/no/anchor/branches', ['foo']),
+            ('http://example.com/no/anchor/branches', (None, ['foo'])))
+        self.assertEqual(
+            hg.parseurl('http://example.com/an/anchor/branches#bar', ['foo']),
+            ('http://example.com/an/anchor/branches', ('bar', ['foo'])))
+        self.assertEqual(hg.parseurl(
+            'http://example.com/an/anchor/branches-None#foo', None),
+            ('http://example.com/an/anchor/branches-None', ('foo', [])))
+        self.assertEqual(hg.parseurl('http://example.com/'),
+                         ('http://example.com/', (None, [])))
+        self.assertEqual(hg.parseurl('http://example.com'),
+                         ('http://example.com/', (None, [])))
+        self.assertEqual(hg.parseurl('http://example.com#foo'),
+                         ('http://example.com/', ('foo', [])))
+
+if __name__ == '__main__':
+    import silenttestrunner
+    silenttestrunner.main(__name__)