[py-svn] commit/pytest: Graham Horler: Remove check for "_" prefix on python functions (use python_functions)

Bitbucket commits-noreply at bitbucket.org
Wed Nov 28 09:18:24 CET 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/54a6130223e4/
changeset:   54a6130223e4
user:        Graham Horler
date:        2012-11-27 17:58:08
summary:     Remove check for "_" prefix on python functions (use python_functions)

(See IRC hpk 2012-11-27 14:56: after the python_functions customization
 was introduced, it makes sense to disregard the preliminary "_" check)
affected #:  2 files

diff -r 2296406d61603c56d54541cf38cee8d1e373ab8a -r 54a6130223e48a6c424dc74d1f72c6793d4ece18 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -277,13 +277,12 @@
                 if name in seen:
                     continue
                 seen[name] = True
-                if name[0] != "_":
-                    res = self.makeitem(name, obj)
-                    if res is None:
-                        continue
-                    if not isinstance(res, list):
-                        res = [res]
-                    l.extend(res)
+                res = self.makeitem(name, obj)
+                if res is None:
+                    continue
+                if not isinstance(res, list):
+                    res = [res]
+                l.extend(res)
         l.sort(key=lambda item: item.reportinfo()[:2])
         return l
 


diff -r 2296406d61603c56d54541cf38cee8d1e373ab8a -r 54a6130223e48a6c424dc74d1f72c6793d4ece18 testing/python/collect.py
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -659,6 +659,28 @@
         "*2 passed*",
     ])
 
+
+def test_customized_python_discovery_functions(testdir):
+    testdir.makeini("""
+        [pytest]
+        python_functions=_test
+    """)
+    p = testdir.makepyfile("""
+        def _test_underscore():
+            pass
+    """)
+    result = testdir.runpytest("--collectonly", "-s")
+    result.stdout.fnmatch_lines([
+        "*_test_underscore*",
+    ])
+
+    result = testdir.runpytest()
+    assert result.ret == 0
+    result.stdout.fnmatch_lines([
+        "*1 passed*",
+    ])
+
+
 def test_collector_attributes(testdir):
     testdir.makeconftest("""
         import pytest

Repository URL: https://bitbucket.org/hpk42/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