changeset 17617:4038071af82a

tests: run test-hybridencode.py over both Python and C encoders This ensures that the two always give the same answers.
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 18 Sep 2012 16:09:02 -0700
parents 9535a0dc41f2
children 7840d81a80ec
files tests/test-hybridencode.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-hybridencode.py	Tue Sep 18 15:42:19 2012 -0700
+++ b/tests/test-hybridencode.py	Tue Sep 18 16:09:02 2012 -0700
@@ -1,12 +1,22 @@
-from mercurial import store
+from mercurial import parsers, store
 
 hybridencode = lambda f: store._hybridencode(f, True)
 
-enc = hybridencode # used for 'dotencode' repo format
+pathencode = getattr(parsers, 'pathencode', None)
+def pencode(f):
+    pe = pathencode(f)
+    if pe is None:
+        return store._hashencode(store.encodedir(f), True)
+    return pe
 
 def show(s):
     print "A = '%s'" % s.encode("string_escape")
-    print "B = '%s'" % enc(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")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")
@@ -450,4 +460,3 @@
           'VWXYZ-1234567890-xxxxxxxxx-xxxxxxxxx-xxxxxxxx-xxxx'
           'xxxxx-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwww'
           'wwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww-wwwwwwwww')
-