changeset 17622:57bf86677daa

test-hybridencode: use store._dothybridencode(s) and compare it with the result of store._hybridencode(s, True)
author Adrian Buehlmann <adrian@cadifra.com>
date Wed, 19 Sep 2012 11:39:18 +0200
parents 1a42f19ad958
children 448e6ed7c557
files tests/test-hybridencode.py
diffstat 1 files changed, 11 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-hybridencode.py	Wed Sep 19 11:39:07 2012 +0200
+++ b/tests/test-hybridencode.py	Wed Sep 19 11:39:18 2012 +0200
@@ -1,22 +1,17 @@
-from mercurial import parsers, store
-
-hybridencode = lambda f: store._hybridencode(f, True)
-
-pathencode = getattr(parsers, 'pathencode', None)
-def pencode(f):
-    pe = pathencode(f)
-    if pe is None:
-        return store._hashencode(store.encodedir(f), True)
-    return pe
+from mercurial import store
 
 def show(s):
+    # show test input
     print "A = '%s'" % s.encode("string_escape")
-    he = hybridencode(s)
-    print "B = '%s'" % he.encode("string_escape")
-    if pathencode:
-        pe = pencode(s)
-        if pe != he:
-            print "N = '%s'" % pe.encode("string_escape")
+
+    # show the result of the C implementation, if available
+    h = store._dothybridencode(s)
+    print "B = '%s'" % h.encode("string_escape")
+
+    # compare it with reference implementation in Python
+    r = store._hybridencode(s, True)
+    if h != r:
+        print "R = '%s'" % r.encode("string_escape")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")