D3526: tests: port test-ui-config to Python 3

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Thu May 10 11:15:39 EDT 2018


durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Slight test output changes to make life easier.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist
  tests/test-ui-config.py
  tests/test-ui-config.py.out

CHANGE DETAILS

diff --git a/tests/test-ui-config.py.out b/tests/test-ui-config.py.out
--- a/tests/test-ui-config.py.out
+++ b/tests/test-ui-config.py.out
@@ -6,7 +6,7 @@
 'false'
 None
 ---
-values.string is not a boolean ('string value')
+'values.string is not a boolean (\'string value\')'
 True
 False
 False
diff --git a/tests/test-ui-config.py b/tests/test-ui-config.py
--- a/tests/test-ui-config.py
+++ b/tests/test-ui-config.py
@@ -2,8 +2,12 @@
 from mercurial import (
     dispatch,
     error,
+    pycompat,
     ui as uimod,
 )
+from mercurial.utils import (
+    stringutil,
+)
 
 testui = uimod.ui.load()
 
@@ -46,59 +50,62 @@
     b'date.invalid=0'
     ])
 
-print(repr(testui.configitems(b'values')))
-print(repr(testui.configitems(b'lists')))
+def pprint(obj):
+    return stringutil.pprint(obj, bprefix=False).decode('ascii')
+
+print(pprint(testui.configitems(b'values')))
+print(pprint(testui.configitems(b'lists')))
 print("---")
-print(repr(testui.config(b'values', b'string')))
-print(repr(testui.config(b'values', b'bool1')))
-print(repr(testui.config(b'values', b'bool2')))
-print(repr(testui.config(b'values', b'unknown')))
+print(pprint(testui.config(b'values', b'string')))
+print(pprint(testui.config(b'values', b'bool1')))
+print(pprint(testui.config(b'values', b'bool2')))
+print(pprint(testui.config(b'values', b'unknown')))
 print("---")
 try:
-    print(repr(testui.configbool(b'values', b'string')))
+    print(pprint(testui.configbool(b'values', b'string')))
 except error.ConfigError as inst:
-    print(inst)
-print(repr(testui.configbool(b'values', b'bool1')))
-print(repr(testui.configbool(b'values', b'bool2')))
-print(repr(testui.configbool(b'values', b'bool2', True)))
-print(repr(testui.configbool(b'values', b'unknown')))
-print(repr(testui.configbool(b'values', b'unknown', True)))
+    print(pprint(pycompat.bytestr(inst)))
+print(pprint(testui.configbool(b'values', b'bool1')))
+print(pprint(testui.configbool(b'values', b'bool2')))
+print(pprint(testui.configbool(b'values', b'bool2', True)))
+print(pprint(testui.configbool(b'values', b'unknown')))
+print(pprint(testui.configbool(b'values', b'unknown', True)))
 print("---")
-print(repr(testui.configint(b'values', b'int1')))
-print(repr(testui.configint(b'values', b'int2')))
+print(pprint(testui.configint(b'values', b'int1')))
+print(pprint(testui.configint(b'values', b'int2')))
 print("---")
-print(repr(testui.configlist(b'lists', b'list1')))
-print(repr(testui.configlist(b'lists', b'list2')))
-print(repr(testui.configlist(b'lists', b'list3')))
-print(repr(testui.configlist(b'lists', b'list4')))
-print(repr(testui.configlist(b'lists', b'list4', [b'foo'])))
-print(repr(testui.configlist(b'lists', b'list5')))
-print(repr(testui.configlist(b'lists', b'list6')))
-print(repr(testui.configlist(b'lists', b'list7')))
-print(repr(testui.configlist(b'lists', b'list8')))
-print(repr(testui.configlist(b'lists', b'list9')))
-print(repr(testui.configlist(b'lists', b'list10')))
-print(repr(testui.configlist(b'lists', b'list11')))
-print(repr(testui.configlist(b'lists', b'list12')))
-print(repr(testui.configlist(b'lists', b'list13')))
-print(repr(testui.configlist(b'lists', b'list14')))
-print(repr(testui.configlist(b'lists', b'list15')))
-print(repr(testui.configlist(b'lists', b'list16')))
-print(repr(testui.configlist(b'lists', b'list17')))
-print(repr(testui.configlist(b'lists', b'list18')))
-print(repr(testui.configlist(b'lists', b'unknown')))
-print(repr(testui.configlist(b'lists', b'unknown', b'')))
-print(repr(testui.configlist(b'lists', b'unknown', b'foo')))
-print(repr(testui.configlist(b'lists', b'unknown', [b'foo'])))
-print(repr(testui.configlist(b'lists', b'unknown', b'foo bar')))
-print(repr(testui.configlist(b'lists', b'unknown', b'foo, bar')))
-print(repr(testui.configlist(b'lists', b'unknown', [b'foo bar'])))
-print(repr(testui.configlist(b'lists', b'unknown', [b'foo', b'bar'])))
+print(pprint(testui.configlist(b'lists', b'list1')))
+print(pprint(testui.configlist(b'lists', b'list2')))
+print(pprint(testui.configlist(b'lists', b'list3')))
+print(pprint(testui.configlist(b'lists', b'list4')))
+print(pprint(testui.configlist(b'lists', b'list4', [b'foo'])))
+print(pprint(testui.configlist(b'lists', b'list5')))
+print(pprint(testui.configlist(b'lists', b'list6')))
+print(pprint(testui.configlist(b'lists', b'list7')))
+print(pprint(testui.configlist(b'lists', b'list8')))
+print(pprint(testui.configlist(b'lists', b'list9')))
+print(pprint(testui.configlist(b'lists', b'list10')))
+print(pprint(testui.configlist(b'lists', b'list11')))
+print(pprint(testui.configlist(b'lists', b'list12')))
+print(pprint(testui.configlist(b'lists', b'list13')))
+print(pprint(testui.configlist(b'lists', b'list14')))
+print(pprint(testui.configlist(b'lists', b'list15')))
+print(pprint(testui.configlist(b'lists', b'list16')))
+print(pprint(testui.configlist(b'lists', b'list17')))
+print(pprint(testui.configlist(b'lists', b'list18')))
+print(pprint(testui.configlist(b'lists', b'unknown')))
+print(pprint(testui.configlist(b'lists', b'unknown', b'')))
+print(pprint(testui.configlist(b'lists', b'unknown', b'foo')))
+print(pprint(testui.configlist(b'lists', b'unknown', [b'foo'])))
+print(pprint(testui.configlist(b'lists', b'unknown', b'foo bar')))
+print(pprint(testui.configlist(b'lists', b'unknown', b'foo, bar')))
+print(pprint(testui.configlist(b'lists', b'unknown', [b'foo bar'])))
+print(pprint(testui.configlist(b'lists', b'unknown', [b'foo', b'bar'])))
 print("---")
-print(repr(testui.configdate(b'date', b'epoch')))
-print(repr(testui.configdate(b'date', b'birth')))
+print(pprint(testui.configdate(b'date', b'epoch')))
+print(pprint(testui.configdate(b'date', b'birth')))
 
-print(repr(testui.config(b'values', b'String')))
+print(pprint(testui.config(b'values', b'String')))
 
 def function():
     pass
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -453,6 +453,7 @@
 test-template-engine.t
 test-treemanifest.t
 test-ui-color.py
+test-ui-config.py
 test-ui-verbosity.py
 test-unamend.t
 test-uncommit.t



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


More information about the Mercurial-devel mailing list