Anonymous avatar Anonymous committed 925420a

Update dependency to latest pytest. Add multiprocessing test and tox.

Comments (0)

Files changed (4)

 
     pip install pytest-xdist
 
-For backward compatability there is no dependancy on the new pytest package name, install pytest if
-you don't already have it::
-
-    pip install pytest
-
 .. NOTE::
 
     Ensure you use pip instead of easy_install as the latter does not correctly install the
 import setuptools
 
 setuptools.setup(name='pytest-cov',
-                 version='1.5',
-                 description='py.test plugin for coverage reporting with support for both centralised and distributed testing, including subprocesses',
+                 version='1.6',
+                 description='py.test plugin for coverage reporting with support for both centralised and distributed testing, including subprocesses and multiprocessing',
                  long_description=open('README.txt').read().strip(),
                  author='Meme Dough',
                  author_email='memedough@gmail.com',
                  url='http://bitbucket.org/memedough/pytest-cov/overview',
                  py_modules=['pytest_cov'],
-                 install_requires=['py>=1.3.4',
-                                   'cov-core>=1.3'],
+                 install_requires=['pytest>=2.2.3',
+                                   'cov-core>=1.6'],
                  entry_points={'pytest11': ['pytest_cov = pytest_cov']},
                  license='MIT License',
                  zip_safe=False,

test_pytest_cov.py

 - If py 3.1 then can have tx for py 3.1, but problems if tx for py 2 or py 3.0.
 
 - For py 3.0 coverage seems to give incorrect results, it reports all
-  covered except the one line which it should have actualy covered.
+  covered except the one line which it should have actually covered.
   Issue reported upstream, also only problem with pass statement and
-  is find with simple assignment statement.
+  is fine with simple assignment statement.
 """
 
 import py
 import os
+import sys
 
 pytest_plugins = 'pytester', 'cov'
 
         a = True
     if version == (3, 1):
         a = True
+    if version == (3, 2):
+        a = True
 '''
 
 SCRIPT_CHILD = '''
     assert cov is None
 '''
 
+MULTIPROCESSING_SCRIPT = '''
+import multiprocessing
+
+def target_fn():
+    a = True
+    return a
+
+def test_run_target():
+    p = multiprocessing.Process(target=target_fn)
+    p.start()
+    p.join()
+'''
+
 
 def test_central(testdir):
     script = testdir.makepyfile(SCRIPT)
 
     result.stdout.fnmatch_lines([
             '*- coverage: platform *, python * -*',
-            'test_central * 18 * 72%*',
+            'test_central * 20 * 70%*',
             '*10 passed*'
             ])
     assert result.ret == 0
 
     result.stdout.fnmatch_lines([
             '*- coverage: platform *, python * -*',
-            'test_dist_collocated * 18 * 72%*',
+            'test_dist_collocated * 20 * 70%*',
             '*10 passed*'
             ])
     assert result.ret == 0
 
     result.stdout.fnmatch_lines([
             '*- coverage: platform *, python * -*',
-            'test_dist_not_collocated * 18 * 72%*',
+            'test_dist_not_collocated * 20 * 70%*',
             '*10 passed*'
             ])
     assert result.ret == 0
     assert not matching_lines
 
 
-@py.test.mark.skipif('sys.version_info[:2] >= (3, 0)')
 def test_dist_missing_data(testdir):
-    if not os.path.exists('/usr/local/python255-empty/bin/python'):
-        py.test.skip('this test needs python without pytest-cov installed in /usr/local/python255-empty/bin/python')
+    version = sys.version_info[:2]
+    if version == (2, 4):
+        exe = '/usr/local/py24/bin/python'
+    if version == (2, 5):
+        exe = '/usr/local/py25/bin/python'
+    if version == (2, 6):
+        exe = '/usr/local/py26/bin/python'
+    if version == (2, 7):
+        exe = '/usr/local/py27/bin/python'
+    if version == (3, 0):
+        exe = '/usr/local/py30/bin/python3.0'
+    if version == (3, 1):
+        exe = '/usr/local/py31/bin/python3.1'
+    if version == (3, 2):
+        exe = '/usr/local/py32/bin/python3.2'
 
     script = testdir.makepyfile(SCRIPT)
 
                                '--cov=%s' % script.dirpath(),
                                '--cov-report=term-missing',
                                '--dist=load',
-                               '--tx=popen//python=/usr/local/python255-empty/bin/python',
+                               '--tx=popen//python=%s' % exe,
                                script)
 
     result.stdout.fnmatch_lines([
             '*1 passed*'
             ])
     assert result.ret == 0
+
+
+def test_multiprocessing_subprocess(testdir):
+    py.test.importorskip('multiprocessing.util')
+
+    script = testdir.makepyfile(MULTIPROCESSING_SCRIPT)
+
+    result = testdir.runpytest('-v',
+                               '--cov=%s' % script.dirpath(),
+                               '--cov-report=term-missing',
+                               script)
+
+    result.stdout.fnmatch_lines([
+            '*- coverage: platform *, python * -*',
+            'test_multiprocessing_subprocess * 8 * 100%*',
+            '*1 passed*'
+            ])
+    assert result.ret == 0
+[tox]
+envlist = py24, py25, py26, py27, py30, py31, py32
+
+[testenv]
+deps = pytest
+       pytest-xdist
+commands = py.test -v test_pytest_cov.py
+
+[testenv:py24]
+basepython = /usr/local/py24/bin/python
+
+[testenv:py25]
+basepython = /usr/local/py25/bin/python
+
+[testenv:py26]
+basepython = /usr/local/py26/bin/python
+
+[testenv:py27]
+basepython = /usr/local/py27/bin/python
+
+[testenv:py30]
+basepython = /usr/local/py30/bin/python3.0
+
+[testenv:py31]
+basepython = /usr/local/py31/bin/python3.1
+
+[testenv:py32]
+basepython = /usr/local/py32/bin/python3.2
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.