File tree 2 files changed +39
-0
lines changed
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ """This utility script gathers the top level packages for wich coverage should
2
+ be measured.
3
+ """
4
+ import os
5
+
6
+ PROJECT_ROOT = os .path .abspath (os .path .dirname (os .path .dirname (__file__ )))
7
+
8
+
9
+ def gather_packages (cwd = PROJECT_ROOT ):
10
+ """Return a list of all directories in cwd containing an ``__init__.py`` file."""
11
+ dirpaths = (path for path in os .listdir (PROJECT_ROOT ) if os .path .isdir (path ))
12
+ package_names = [
13
+ os .path .basename (path ) for path in dirpaths if "__init__.py" in os .listdir (path )
14
+ ]
15
+ return package_names
16
+
17
+ def generate_coverage_py_string (cwd = PROJECT_ROOT ):
18
+ """Generate a string on the form ``--cov PACKAGE_1 --cov PACKAGE_2 ...`` such
19
+ that all packages found in cwd are traced using pytest-cov.
20
+ """
21
+ packages = gather_packages (cwd )
22
+ assert packages
23
+
24
+ return "--cov " + " --cov " .join (packages )
25
+
26
+ def main ():
27
+ cov_string = generate_coverage_py_string ()
28
+ print (cov_string )
29
+
30
+ if __name__ == "__main__" :
31
+ main ()
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Script for running the test suite with branch coverage.
4
+
5
+ # Coverage.py caches interfere with subsequent runs for some reason
6
+ rm -f .coverage*
7
+
8
+ python -m pytest tests/ $( python .travis/covstring.py) --cov-branch
You can’t perform that action at this time.
0 commit comments