[PATCH 2 of 3 v4] tests: make test-hybridencode.py test both Python and C encoders

Bryan O'Sullivan bos at serpentine.com
Thu Sep 6 18:31:17 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1346971132 25200
# Node ID 4a87c26bd06144d628ae6b160309d47e0754dc5d
# Parent  831e86e4a9e9621c32c9c3fd314790d7a0276f22
tests: make test-hybridencode.py test both Python and C encoders

More importantly, it ensures that they always give the same answers.

diff --git a/tests/test-hybridencode.py b/tests/test-hybridencode.py
--- a/tests/test-hybridencode.py
+++ b/tests/test-hybridencode.py
@@ -1,13 +1,18 @@
-from mercurial import store
+from mercurial import store, parsers
 
 auxencode = lambda f: store._auxencode(f, True)
 hybridencode = lambda f: store._hybridencode(f, auxencode)
 
-enc = hybridencode # used for 'dotencode' repo format
+pathencode = getattr(parsers, 'pathencode', None)
 
 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 = pathencode(s)
+        if pe != he:
+            print "N = '%s'" % pe.encode("string_escape")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")


More information about the Mercurial-devel mailing list