Debian Codegraph @

debian/patches/proposed_upstream__doctest.path

raw
1 # HG changeset patch
2 # User Julien Cristau <[email protected]>
3 # Date 1589916203 -7200
4 # Tue May 19 21:23:23 2020 +0200
5 # Node ID de789b6b188b62cf38c5c5cfe760cff9a48c52f5
6 # Parent 3b7aabd02e11fcfc015b3a90a0c52d971a7b8a83
7 test: make test-doctest.py work when it's not run from a mercurial repo
8
9 This assumption fails when building and running tests from a source
10 tarball, e.g.
11
12 Differential Revision: https://phab.mercurial-scm.org/D8571
13 ---
14 tests/test-doctest.py | 23 ++++++++++++-----------
15 1 file changed, 12 insertions(+), 11 deletions(-)
16
17 --- a/tests/test-doctest.py
18 +++ b/tests/test-doctest.py
19 @@ -4,7 +4,6 @@
20 import doctest
21 import os
22 import re
23 -import subprocess
24 import sys
25
26 if 'TERM' in os.environ:
27 @@ -74,23 +73,15 @@ testmod_arg_overrides = {
28 'tests.test-url': [{'optionflags': doctest.NORMALIZE_WHITESPACE}],
29 }
30
31 -fileset = 'set:(**.py)'
32 +cwd = os.path.dirname(os.environb[b"TESTDIR"])
33
34 -cwd = os.path.dirname(os.environ["TESTDIR"])
35 -
36 -if not os.path.isdir(os.path.join(cwd, ".hg")):
37 - sys.exit(0)
38 -
39 -files = subprocess.check_output(
40 - [
41 - "sh",
42 - "-c",
43 - "set -e; . helpers-testrepo.sh; testrepohg files --print0 \"%s\""
44 - % fileset,
45 - ],
46 - shell=False,
47 - cwd=cwd,
48 -).split(b'\0')
49 +files = []
50 +for dirpath, dirnames, filenames in os.walk(cwd):
51 + excludeddirindexes = reversed([i for i, dir in enumerate(dirnames) if dir == b'build' or dir.startswith(b'.')])
52 + for i in excludeddirindexes:
53 + del dirnames[i]
54 + # include all .py files, removing the cwd + dirsep prefix
55 + files.extend(os.path.join(dirpath, f)[len(cwd) + 1:] for f in filenames if f.endswith(b'.py'))
56
57 if sys.version_info[0] >= 3:
58 cwd = os.fsencode(cwd)