Commits

Ronny Pfannschmidt committed 1bad54c

finalize some patches

Comments (0)

Files changed (4)

collectonly-session-no-items

-# HG changeset patch
-# Parent f8f976918f25fdfdfa38e239801b1ac60e88f9c6
-dont fail in collectonly if session doesnt yet have the items attribute, fixes #115
-
-diff --git a/CHANGELOG b/CHANGELOG
---- a/CHANGELOG
-+++ b/CHANGELOG
-@@ -16,6 +16,8 @@ Changes between 2.2.1 and 2.2.2.dev
-   this helps xdist serialization/deserialization of extended/customized reports
- - add support for more quiet collectonly, which only prints the number of tests per file,
-   instead of the nodeids
-+- fix issue115: make --collectonly robust against session failing
-+  before it has items
- 
- Changes between 2.2.0 and 2.2.1
- ----------------------------------------
-diff --git a/_pytest/terminal.py b/_pytest/terminal.py
---- a/_pytest/terminal.py
-+++ b/_pytest/terminal.py
-@@ -265,7 +265,7 @@ class TerminalReporter:
- 
-     def pytest_collection_finish(self, session):
-         if self.config.option.collectonly:
--            self._printcollecteditems(session.items)
-+            self._printcollecteditems(getattr(session, 'items', ()))
-             if self.stats.get('failed'):
-                 self._tw.sep("!", "collection failures")
-                 for rep in self.stats.get('failed'):
-diff --git a/testing/test_terminal.py b/testing/test_terminal.py
---- a/testing/test_terminal.py
-+++ b/testing/test_terminal.py
-@@ -270,6 +270,17 @@ class TestCollectonly:
-             '*test_fun.py: 1*',
-         ])
- 
-+    def test_collectonly_missing_path(self, testdir):
-+        """this checks issue 115,
-+            failure in parseargs will cause session
-+            not to have the items attribute
-+        """
-+        result = testdir.runpytest("--collectonly", "uhm_missing_path")
-+        assert result.ret == 3
-+        result.stderr.fnmatch_lines([
-+            '*ERROR: file not found*',
-+        ])
-+
- 
- def test_repr_python_version(monkeypatch):
-     try:

more-quiet-collectonly

-# HG changeset patch
-# Parent 29ec3dec63891b8e4f633ef4fed13c61b9e4ccb2
-more quit collectonly shows only files and the number of tests in them
-
-diff --git a/CHANGELOG b/CHANGELOG
---- a/CHANGELOG
-+++ b/CHANGELOG
-@@ -14,6 +14,8 @@ Changes between 2.2.1 and 2.2.2.dev
- - fix crash resulting from calling monkeypatch undo a second time
- - extend reports accepting kwargs to set arbitrary additional attributes
-   this helps xdist serialization/deserialization of extended/customized reports
-+- add support for more quiet collectonly, which only prints the number of tests per file,
-+  instead of the nodeids
- 
- Changes between 2.2.0 and 2.2.1
- ----------------------------------------
-diff --git a/_pytest/terminal.py b/_pytest/terminal.py
---- a/_pytest/terminal.py
-+++ b/_pytest/terminal.py
-@@ -282,10 +282,18 @@ class TerminalReporter:
-         # we take care to leave out Instances aka ()
-         # because later versions are going to get rid of them anyway
-         if self.config.option.verbose < 0:
--            for item in items:
--                nodeid = item.nodeid
--                nodeid = nodeid.replace("::()::", "::")
--                self._tw.line(nodeid)
-+            if self.config.option.verbose < -1:
-+                counts = {}
-+                for item in items:
-+                    name = item.nodeid.split('::', 1)[0]
-+                    counts[name] = counts.get(name, 0) + 1
-+                for name, count in sorted(counts.items()):
-+                    self._tw.line("%s %d" % (name, count))
-+            else:
-+                for item in items:
-+                    nodeid = item.nodeid
-+                    nodeid = nodeid.replace("::()::", "::")
-+                    self._tw.line(nodeid)
-             return
-         stack = []
-         indent = ""
-diff --git a/testing/test_terminal.py b/testing/test_terminal.py
---- a/testing/test_terminal.py
-+++ b/testing/test_terminal.py
-@@ -256,6 +256,20 @@ class TestCollectonly:
-             *1 error*
-         """).strip())
- 
-+    def test_collectonly_quiet(self, testdir):
-+        testdir.makepyfile("def test_foo(): pass")
-+        result = testdir.runpytest("--collectonly", "-q")
-+        result.stdout.fnmatch_lines([
-+            '*test_foo*',
-+        ])
-+
-+    def test_collectonly_quiet(self, testdir):
-+        testdir.makepyfile(test_fun="def test_foo(): pass")
-+        result = testdir.runpytest("--collectonly", "-qq")
-+        result.stdout.fnmatch_lines([
-+            '*test_fun.py: 1*',
-+        ])
-+
- 
- def test_repr_python_version(monkeypatch):
-     try:

parametrize-indirect

-# HG changeset patch
-# Parent 6ef58a23837631d521e24ba7100a8cc40cb67c5e
-test & fix - metafunc.parametrize shouldnt check if indirect params are funcarg names
-
-diff --git a/CHANGELOG b/CHANGELOG
---- a/CHANGELOG
-+++ b/CHANGELOG
-@@ -9,6 +9,7 @@ Changes between 2.2.1 and 2.2.2.dev
-   test directory was renamed and some pyc/__pycache__ remain
- - fix issue106: allow parametrize to be applied multiple times
-   e.g. from module, class and at function level.
-+- don't check of indirect parameters are funcarg names
- - add chdir method to monkeypatch funcarg
- - fix crash resulting from calling monkeypatch undo a second time
- - extend reports accepting kwargs to set arbitrary additional attributes
-diff --git a/_pytest/python.py b/_pytest/python.py
---- a/_pytest/python.py
-+++ b/_pytest/python.py
-@@ -629,9 +629,11 @@ class Metafunc:
-         if not isinstance(argnames, (tuple, list)):
-             argnames = (argnames,)
-             argvalues = [(val,) for val in argvalues]
--        for arg in argnames:
--            if arg not in self.funcargnames:
--                raise ValueError("%r has no argument %r" %(self.function, arg))
-+        if not indirect:
-+            #XXX should we also check for the opposite case?
-+            for arg in argnames:
-+                if arg not in self.funcargnames:
-+                    raise ValueError("%r has no argument %r" %(self.function, arg))
-         valtype = indirect and "params" or "funcargs"
-         if not ids:
-             idmaker = IDMaker()
-diff --git a/testing/test_python.py b/testing/test_python.py
---- a/testing/test_python.py
-+++ b/testing/test_python.py
-@@ -983,11 +983,12 @@ class TestMetafunc:
-         metafunc = funcargs.Metafunc(func)
-         metafunc.parametrize('x', [1], indirect=True)
-         metafunc.parametrize('y', [2,3], indirect=True)
-+        metafunc.parametrize('unnamed', [1], indirect=True)
-         assert len(metafunc._calls) == 2
-         assert metafunc._calls[0].funcargs == {}
-         assert metafunc._calls[1].funcargs == {}
--        assert metafunc._calls[0].params == dict(x=1,y=2)
--        assert metafunc._calls[1].params == dict(x=1,y=3)
-+        assert metafunc._calls[0].params == dict(x=1,y=2, unnamed=1)
-+        assert metafunc._calls[1].params == dict(x=1,y=3, unnamed=1)
- 
-     def test_addcalls_and_parametrize_indirect(self):
-         def func(x, y): pass
-parametrize-indirect
-more-quiet-collectonly
-collectonly-session-no-items
 parametrize-items
 regendoc-pytesthighlight #+doc
 fnmatch-python-test-names