diff options
author | Thomas Kluyver <takowl@gmail.com> | 2013-10-20 20:52:11 -0700 |
---|---|---|
committer | Thomas Kluyver <takowl@gmail.com> | 2013-10-20 20:52:11 -0700 |
commit | 34bd03fc6abad0c6b4a823ded8a8c42f0eb5fcfa (patch) | |
tree | f42d1750733faf38cb7a602c8b27e8e59541552d | |
parent | c107909f1fb218f773daf65d6f3d862aedb6809e (diff) | |
download | pexpect-git-34bd03fc6abad0c6b4a823ded8a8c42f0eb5fcfa.tar.gz |
Measure code coverage in interact tests
-rw-r--r-- | .coveragerc | 1 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | tests/PexpectTestCase.py | 6 | ||||
-rwxr-xr-x | tests/interact.py | 7 | ||||
-rw-r--r-- | tests/interact_unicode.py | 7 |
5 files changed, 21 insertions, 1 deletions
diff --git a/.coveragerc b/.coveragerc index 200827d..7e2d9e2 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,2 +1,3 @@ [run] source = pexpect +parallel = True @@ -5,3 +5,4 @@ build/ dist/ MANIFEST *~ +.coverage* diff --git a/tests/PexpectTestCase.py b/tests/PexpectTestCase.py index a9c056f..619d094 100644 --- a/tests/PexpectTestCase.py +++ b/tests/PexpectTestCase.py @@ -28,11 +28,15 @@ class PexpectTestCase(unittest.TestCase): def setUp(self): self.PYTHONBIN = sys.executable self.original_path = os.getcwd() - newpath = os.path.join (os.environ['PROJECT_PEXPECT_HOME'], 'tests') + project_dir = os.environ['PROJECT_PEXPECT_HOME'] + newpath = os.path.join (project_dir, 'tests') os.chdir (newpath) + os.environ['COVERAGE_PROCESS_START'] = os.path.join(project_dir, '.coveragerc') + os.environ['COVERAGE_FILE'] = os.path.join(project_dir, '.coverage') print('\n', self.id(), end=' ') sys.stdout.flush() unittest.TestCase.setUp(self) + def tearDown(self): os.chdir (self.original_path) diff --git a/tests/interact.py b/tests/interact.py index b0488b1..3ea8c5b 100755 --- a/tests/interact.py +++ b/tests/interact.py @@ -18,6 +18,13 @@ PEXPECT LICENSE OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ''' +try: + # This allows coverage to measure code run in this process + import coverage + coverage.process_startup() +except ImportError: + pass + import pexpect import sys diff --git a/tests/interact_unicode.py b/tests/interact_unicode.py index 8312d56..873bb71 100644 --- a/tests/interact_unicode.py +++ b/tests/interact_unicode.py @@ -2,6 +2,13 @@ ''' Just like interact.py, but using spawnu instead of spawn ''' +try: + # This allows coverage to measure code run in this process + import coverage + coverage.process_startup() +except ImportError: + pass + import pexpect import sys |