tests/test-doctest.py
changeset 44656 15aef805619d
parent 44565 0af56d3ee24c
child 45633 5a19d7c9129b
--- a/tests/test-doctest.py	Sun Mar 29 14:31:59 2020 -0700
+++ b/tests/test-doctest.py	Sun Mar 29 15:29:39 2020 -0700
@@ -68,20 +68,26 @@
     'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
 }
 
-doctest_indicator = '\n\\s*>>> '
-fileset = 'set:(**.py and grep("%s"))' % doctest_indicator
+fileset = 'set:(**.py)'
+
+cwd = os.path.dirname(os.environ["TESTDIR"])
 
 files = subprocess.check_output(
-    "hg files --print0 '%s'" % fileset,
-    shell=True,
-    cwd=os.path.dirname(os.environ['TESTDIR']),
+    "hg files --print0 \"%s\"" % fileset, shell=True, cwd=cwd,
 ).split(b'\0')
 
+if sys.version_info[0] >= 3:
+    cwd = os.fsencode(cwd)
+
 mods_tested = set()
 for f in files:
     if not f:
         continue
 
+    with open(os.path.join(cwd, f), "rb") as fh:
+        if not re.search(br'\n\s*>>>', fh.read()):
+            continue
+
     if ispy3:
         f = f.decode()