[Pytest-commit] commit/pytest: 8 new changesets

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Mar 23 20:42:28 CET 2015


8 new commits in pytest:

https://bitbucket.org/pytest-dev/pytest/commits/a16e5e78cac4/
Changeset:   a16e5e78cac4
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-21 22:06:25+00:00
Summary:     #463

Raise a ValueError early if user misspells 'parametrize' as 'parameterize'.
Affected #:  2 files

diff -r 39361b33346e784e4f6359dbdba9c9957a8e4cd7 -r a16e5e78cac4c10a610ca54497d72e2b845f6449 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -143,6 +143,13 @@
 
 def pytest_generate_tests(metafunc):
     try:
+        # this misspelling is common - raise a specific error to alert the user
+        markers = metafunc.function.parameterize
+        msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
+        raise ValueError(msg.format(metafunc.function.__name__))
+    except AttributeError:
+        pass
+    try:
         markers = metafunc.function.parametrize
     except AttributeError:
         return

diff -r 39361b33346e784e4f6359dbdba9c9957a8e4cd7 -r a16e5e78cac4c10a610ca54497d72e2b845f6449 testing/python/metafunc.py
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -692,6 +692,21 @@
         reprec = testdir.inline_run()
         reprec.assertoutcome(passed=4)
 
+    @pytest.mark.issue463
+    def test_parameterize_misspelling(self, testdir):
+        testdir.makepyfile("""
+            import pytest
+
+            @pytest.mark.parameterize("x", range(2))
+            def test_foo(x):
+                pass
+        """)
+        reprec = testdir.inline_run('--collectonly')
+        failures = reprec.getfailures()
+        assert len(failures) == 1
+        expectederror = "ValueError: test_foo has mark 'parameterize', spelling should be 'parametrize'"
+        assert expectederror in failures[0].longrepr.reprcrash.message
+
 
 class TestMarkersWithParametrization:
     pytestmark = pytest.mark.issue308


https://bitbucket.org/pytest-dev/pytest/commits/a9417e486228/
Changeset:   a9417e486228
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-21 22:30:13+00:00
Summary:     Use hasattr instead of try/except
Affected #:  1 file

diff -r a16e5e78cac4c10a610ca54497d72e2b845f6449 -r a9417e4862282c6149524fbfc472aa782c461c74 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -142,13 +142,10 @@
 
 
 def pytest_generate_tests(metafunc):
-    try:
-        # this misspelling is common - raise a specific error to alert the user
-        markers = metafunc.function.parameterize
+    # this misspelling is common - raise a specific error to alert the user
+    if hasattr(metafunc.function, 'parameterize'):
         msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
         raise ValueError(msg.format(metafunc.function.__name__))
-    except AttributeError:
-        pass
     try:
         markers = metafunc.function.parametrize
     except AttributeError:


https://bitbucket.org/pytest-dev/pytest/commits/08a60bf2bacd/
Changeset:   08a60bf2bacd
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-21 22:57:06+00:00
Summary:     Change string format syntax from {} to {0} for py2.6
Affected #:  1 file

diff -r a9417e4862282c6149524fbfc472aa782c461c74 -r 08a60bf2bacda6a285df61b27157d6c5d244f4b2 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -144,7 +144,7 @@
 def pytest_generate_tests(metafunc):
     # this misspelling is common - raise a specific error to alert the user
     if hasattr(metafunc.function, 'parameterize'):
-        msg = "{} has mark 'parameterize', spelling should be 'parametrize'"
+        msg = "{0} has mark 'parameterize', spelling should be 'parametrize'"
         raise ValueError(msg.format(metafunc.function.__name__))
     try:
         markers = metafunc.function.parametrize


https://bitbucket.org/pytest-dev/pytest/commits/fed7915005e6/
Changeset:   fed7915005e6
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-23 19:01:58+00:00
Summary:     Raise specific MarkerError rather than generic ValueError
Affected #:  3 files

diff -r 08a60bf2bacda6a285df61b27157d6c5d244f4b2 -r fed7915005e627ec23eb06a95e0fabbfd0ae389d _pytest/mark.py
--- a/_pytest/mark.py
+++ b/_pytest/mark.py
@@ -1,6 +1,9 @@
 """ generic mechanism for marking and selecting python functions. """
 import py
 
+class MarkerError(Exception):
+    """Error in use of a pytest marker/attribute"""
+
 
 def pytest_namespace():
     return {'mark': MarkGenerator()}

diff -r 08a60bf2bacda6a285df61b27157d6c5d244f4b2 -r fed7915005e627ec23eb06a95e0fabbfd0ae389d _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -4,7 +4,7 @@
 import inspect
 import sys
 import pytest
-from _pytest.mark import MarkDecorator
+from _pytest.mark import MarkDecorator, MarkerError
 from py._code.code import TerminalRepr
 
 import _pytest
@@ -144,8 +144,8 @@
 def pytest_generate_tests(metafunc):
     # this misspelling is common - raise a specific error to alert the user
     if hasattr(metafunc.function, 'parameterize'):
-        msg = "{0} has mark 'parameterize', spelling should be 'parametrize'"
-        raise ValueError(msg.format(metafunc.function.__name__))
+        msg = "{0} has 'parameterize', spelling should be 'parametrize'"
+        raise MarkerError(msg.format(metafunc.function.__name__))
     try:
         markers = metafunc.function.parametrize
     except AttributeError:

diff -r 08a60bf2bacda6a285df61b27157d6c5d244f4b2 -r fed7915005e627ec23eb06a95e0fabbfd0ae389d testing/python/metafunc.py
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -704,7 +704,7 @@
         reprec = testdir.inline_run('--collectonly')
         failures = reprec.getfailures()
         assert len(failures) == 1
-        expectederror = "ValueError: test_foo has mark 'parameterize', spelling should be 'parametrize'"
+        expectederror = "MarkerError: test_foo has 'parameterize', spelling should be 'parametrize'"
         assert expectederror in failures[0].longrepr.reprcrash.message
 
 


https://bitbucket.org/pytest-dev/pytest/commits/ee89f982ea14/
Changeset:   ee89f982ea14
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-23 19:27:53+00:00
Summary:     Change docstring style
Affected #:  1 file

diff -r fed7915005e627ec23eb06a95e0fabbfd0ae389d -r ee89f982ea14fa8c071e919a8efe4a896fd41069 _pytest/mark.py
--- a/_pytest/mark.py
+++ b/_pytest/mark.py
@@ -2,7 +2,9 @@
 import py
 
 class MarkerError(Exception):
-    """Error in use of a pytest marker/attribute"""
+    """
+    Error in use of a pytest marker/attribute.
+    """
 
 
 def pytest_namespace():


https://bitbucket.org/pytest-dev/pytest/commits/174c263a826d/
Changeset:   174c263a826d
Branch:      issue463
User:        pfctdayelise
Date:        2015-03-23 19:28:04+00:00
Summary:     update changelog
Affected #:  1 file

diff -r ee89f982ea14fa8c071e919a8efe4a896fd41069 -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,8 @@
 2.7.0.dev (compared to 2.6.4)
 -----------------------------
 
+- fix issue463: raise specific error for 'parameterize' misspelling.
+
 - fix issue616: conftest.py files and their contained fixutres are now
   properly considered for visibility, independently from the exact
   current working directory and test arguments that are used.


https://bitbucket.org/pytest-dev/pytest/commits/72e40258338b/
Changeset:   72e40258338b
Branch:      issue463
User:        bubenkoff
Date:        2015-03-23 19:41:27+00:00
Summary:     merge with default
Affected #:  7 files

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,7 +1,8 @@
 2.7.0.dev (compared to 2.6.4)
 -----------------------------
 
-- fix issue463: raise specific error for 'parameterize' misspelling.
+- fix issue435: make reload() work when assert rewriting is active.
+  Thanks Daniel Hahler.
 
 - fix issue616: conftest.py files and their contained fixutres are now
   properly considered for visibility, independently from the exact
@@ -59,6 +60,8 @@
 
 - allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff).
 
+- fix issue463: raise specific error for 'parameterize' misspelling (pfctdayelise).
+
 2.6.4
 ----------
 

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 _pytest/assertion/rewrite.py
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -146,6 +146,12 @@
         return self
 
     def load_module(self, name):
+        # If there is an existing module object named 'fullname' in
+        # sys.modules, the loader must use that existing module. (Otherwise,
+        # the reload() builtin will not work correctly.)
+        if name in sys.modules:
+            return sys.modules[name]
+
         co, pyc = self.modules.pop(name)
         # I wish I could just call imp.load_compiled here, but __file__ has to
         # be set properly. In Python 3.2+, this all would be handled correctly

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -778,7 +778,6 @@
         self.fixturenames = fixtureinfo.names_closure
         self._arg2fixturedefs = fixtureinfo.name2fixturedefs
         self.cls = cls
-        self.module = module
         self._calls = []
         self._ids = py.builtin.set()
 

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 doc/en/fixture.txt
--- a/doc/en/fixture.txt
+++ b/doc/en/fixture.txt
@@ -67,7 +67,6 @@
     def test_ehlo(smtp):
         response, msg = smtp.ehlo()
         assert response == 250
-        assert "merlinux" in msg
         assert 0 # for demo purposes
 
 Here, the ``test_ehlo`` needs the ``smtp`` fixture value.  pytest

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 doc/en/projects.txt
--- a/doc/en/projects.txt
+++ b/doc/en/projects.txt
@@ -26,6 +26,7 @@
   `21000 tests <http://buildbot.pypy.org/summary?branch=%3Ctrunk%3E>`_
 * the `MoinMoin <http://moinmo.in>`_ Wiki Engine
 * `sentry <https://getsentry.com/welcome/>`_, realtime app-maintenance and exception tracking
+* `Astropy <http://www.astropy.org/>`_ and `affiliated packages <http://www.astropy.org/affiliated/index.html>`_
 * `tox <http://testrun.org/tox>`_, virtualenv/Hudson integration tool
 * `PIDA <http://pida.co.uk>`_ framework for integrated development
 * `PyPM <http://code.activestate.com/pypm/>`_ ActiveState's package manager

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 testing/test_assertrewrite.py
--- a/testing/test_assertrewrite.py
+++ b/testing/test_assertrewrite.py
@@ -641,3 +641,27 @@
         pyc.write(contents[:strip_bytes], mode='wb')
 
         assert _read_pyc(source, str(pyc)) is None  # no error
+
+    def test_reload_is_same(self, testdir):
+        # A file that will be picked up during collecting.
+        testdir.tmpdir.join("file.py").ensure()
+        testdir.tmpdir.join("pytest.ini").write(py.std.textwrap.dedent("""
+            [pytest]
+            python_files = *.py
+        """))
+
+        testdir.makepyfile(test_fun="""
+            import sys
+            try:
+                from imp import reload
+            except ImportError:
+                pass
+
+            def test_loader():
+                import file
+                assert sys.modules["file"] is reload(file)
+            """)
+        result = testdir.runpytest('-s')
+        result.stdout.fnmatch_lines([
+            "* 1 passed*",
+        ])

diff -r 174c263a826d1fa2752e5ef2b9fba0737ecebe63 -r 72e40258338b0f90ba2d769d09ca827b90223a88 tox.ini
--- a/tox.ini
+++ b/tox.ini
@@ -136,7 +136,7 @@
 minversion=2.0
 plugins=pytester
 #--pyargs --doctest-modules --ignore=.tox
-addopts= -rxsX -vl
+addopts= -rxsX 
 rsyncdirs=tox.ini pytest.py _pytest testing
 python_files=test_*.py *_test.py testing/*/*.py
 python_classes=Test Acceptance


https://bitbucket.org/pytest-dev/pytest/commits/8a9039aed722/
Changeset:   8a9039aed722
User:        bubenkoff
Date:        2015-03-23 19:42:16+00:00
Summary:     merge pfctdayelise/issue463
Affected #:  4 files

diff -r 7177c6ac03d8c1871471282ced80d296522f27b1 -r 8a9039aed7226910656320aec0ef51a27bc93caa CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -60,6 +60,8 @@
 
 - allow to override parametrized fixtures with non-parametrized ones and vice versa (bubenkoff).
 
+- fix issue463: raise specific error for 'parameterize' misspelling (pfctdayelise).
+
 2.6.4
 ----------
 

diff -r 7177c6ac03d8c1871471282ced80d296522f27b1 -r 8a9039aed7226910656320aec0ef51a27bc93caa _pytest/mark.py
--- a/_pytest/mark.py
+++ b/_pytest/mark.py
@@ -1,6 +1,11 @@
 """ generic mechanism for marking and selecting python functions. """
 import py
 
+class MarkerError(Exception):
+    """
+    Error in use of a pytest marker/attribute.
+    """
+
 
 def pytest_namespace():
     return {'mark': MarkGenerator()}

diff -r 7177c6ac03d8c1871471282ced80d296522f27b1 -r 8a9039aed7226910656320aec0ef51a27bc93caa _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -4,7 +4,7 @@
 import inspect
 import sys
 import pytest
-from _pytest.mark import MarkDecorator
+from _pytest.mark import MarkDecorator, MarkerError
 from py._code.code import TerminalRepr
 
 import _pytest
@@ -142,6 +142,10 @@
 
 
 def pytest_generate_tests(metafunc):
+    # this misspelling is common - raise a specific error to alert the user
+    if hasattr(metafunc.function, 'parameterize'):
+        msg = "{0} has 'parameterize', spelling should be 'parametrize'"
+        raise MarkerError(msg.format(metafunc.function.__name__))
     try:
         markers = metafunc.function.parametrize
     except AttributeError:

diff -r 7177c6ac03d8c1871471282ced80d296522f27b1 -r 8a9039aed7226910656320aec0ef51a27bc93caa testing/python/metafunc.py
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -692,6 +692,21 @@
         reprec = testdir.inline_run()
         reprec.assertoutcome(passed=4)
 
+    @pytest.mark.issue463
+    def test_parameterize_misspelling(self, testdir):
+        testdir.makepyfile("""
+            import pytest
+
+            @pytest.mark.parameterize("x", range(2))
+            def test_foo(x):
+                pass
+        """)
+        reprec = testdir.inline_run('--collectonly')
+        failures = reprec.getfailures()
+        assert len(failures) == 1
+        expectederror = "MarkerError: test_foo has 'parameterize', spelling should be 'parametrize'"
+        assert expectederror in failures[0].longrepr.reprcrash.message
+
 
 class TestMarkersWithParametrization:
     pytestmark = pytest.mark.issue308

Repository URL: https://bitbucket.org/pytest-dev/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list