Mercurial > public > mercurial-scm > hg-stable
diff tests/test-hg-parseurl.py @ 37713:11d128a14ec0
tests: port test-hg-parseurl.py to unittest
Differential Revision: https://phab.mercurial-scm.org/D3373
author | Augie Fackler <augie@google.com> |
---|---|
date | Sat, 14 Apr 2018 11:04:58 -0400 |
parents | d26c4af27978 |
children | 5dd71e9ae68a |
line wrap: on
line diff
--- a/tests/test-hg-parseurl.py Sat Apr 14 01:12:55 2018 -0400 +++ b/tests/test-hg-parseurl.py Sat Apr 14 11:04:58 2018 -0400 @@ -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__)