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

Bryan O'Sullivan bos at serpentine.com
Thu Sep 6 16:00:37 CDT 2012


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1346965199 25200
# Node ID a6895cd98f21e69523f54c547b6d7d57207b73c3
# Parent  4839f71413cf418989c99c3f57ced564e3cd2a30
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 "native = '%s'" % pe.encode("string_escape")
     print
 
 show("data/abcdefghijklmnopqrstuvwxyz0123456789 !#%&'()+,-.;=[]^`{}")


More information about the Mercurial-devel mailing list