import doctest
import os
import re
-import subprocess
import sys
ispy3 = sys.version_info[0] >= 3
fileset = 'set:(**.py)'
-cwd = os.path.dirname(os.environ["TESTDIR"])
-
-if not os.path.isdir(os.path.join(cwd, ".hg")):
- sys.exit(0)
-
-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)