proposed_upstream__doctest.path
authorPython Applications Packaging Team <python-apps-team@lists.alioth.debian.org>
Sun, 16 Aug 2020 09:03:07 +0000 (11:03 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Sun, 13 Dec 2020 10:30:51 +0000 (10:30 +0000)
# HG changeset patch
# User Julien Cristau <jcristau@debian.org>
# Date 1589916203 -7200
#      Tue May 19 21:23:23 2020 +0200
# Node ID de789b6b188b62cf38c5c5cfe760cff9a48c52f5
# Parent  3b7aabd02e11fcfc015b3a90a0c52d971a7b8a83
test: make test-doctest.py not assume it's run from a mercurial repo

This assumption fails when building and running tests from a source
tarball, e.g.

Differential Revision: https://phab.mercurial-scm.org/D8571

Gbp-Pq: Name proposed_upstream__doctest.path

tests/test-doctest.py

index abd677f6bed0b95c5960f97e1df2d74bdc900ed7..4360f2c79641a530c3c9b86d11f5ce7c19560cd9 100644 (file)
@@ -6,7 +6,6 @@ from __future__ import print_function
 import doctest
 import os
 import re
-import subprocess
 import sys
 
 ispy3 = sys.version_info[0] >= 3
@@ -70,11 +69,18 @@ testmod_arg_overrides = {
 
 fileset = 'set:(**.py)'
 
-cwd = os.path.dirname(os.environ["TESTDIR"])
-
-files = subprocess.check_output(
-    "hg files --print0 \"%s\"" % fileset, shell=True, cwd=cwd,
-).split(b'\0')
+if ispy3:
+    cwd = os.path.dirname(os.environb[b"TESTDIR"])
+else:
+    cwd = os.path.dirname(os.environ["TESTDIR"])
+
+files = []
+for dirpath, dirnames, filenames in os.walk(cwd):
+    excludeddirindexes = reversed([i for i, dir in enumerate(dirnames) if dir == b'build' or dir.startswith(b'.')])
+    for i in excludeddirindexes:
+        del dirnames[i]
+    # include all .py files, removing the cwd + dirsep prefix
+    files.extend(os.path.join(dirpath, f)[len(cwd) + 1:] for f in filenames if f.endswith(b'.py'))
 
 if sys.version_info[0] >= 3:
     cwd = os.fsencode(cwd)