[py-svn] r29873 - in py/dist/py: documentation test test/testing

briandorsey at codespeak.net briandorsey at codespeak.net
Sat Jul 8 22:37:13 CEST 2006


Author: briandorsey
Date: Sat Jul  8 22:37:12 2006
New Revision: 29873

Modified:
   py/dist/py/documentation/test.txt
   py/dist/py/test/collect.py
   py/dist/py/test/testing/test_collect.py
Log:
Re-enabled support for 'whatever_test.py' files, this time with documentation. 


Modified: py/dist/py/documentation/test.txt
==============================================================================
--- py/dist/py/documentation/test.txt	(original)
+++ py/dist/py/documentation/test.txt	Sat Jul  8 22:37:12 2006
@@ -36,9 +36,9 @@
   py.test
 
 This will automatically collect and run any Python module whose filenames 
-start with ``test_`` from the directory and any subdirectories, starting 
-with the current directory, and run them. Each Python test module is 
-inspected for test methods starting with ``test_``. 
+start with ``test_`` or ends with ``_test`` from the directory and any
+subdirectories, starting with the current directory, and run them. Each 
+Python test module is inspected for test methods starting with ``test_``. 
 
 .. _features: 
 
@@ -87,11 +87,11 @@
 The automated test collection process walks the current
 directory (or the directory given as a command line argument)
 and all its subdirectories and collects python modules with a
-leading ``test_`` filename.  From each test module every function
-with a leading ``test_`` or class with a leading ``Test`` name
-is collected.  The collecting process can be customized at
-directory, module or class level.  (see `collection process`_ 
-for some implementation details). 
+leading ``test_`` or trailing ``_test`` filename.  From each 
+test module every function with a leading ``test_`` or class with 
+a leading ``Test`` name is collected.  The collecting process can 
+be customized at directory, module or class level.  (see 
+`collection process`_ for some implementation details). 
 
 .. _`generative tests`: 
 
@@ -294,8 +294,8 @@
 ------------------------------------------------------------
 
 If you want to integrate doctests, ``py.test`` now by default
-picks up files matching the ``test_*.txt`` pattern and
-processes them as text files containing doctests. 
+picks up files matching the ``test_*.txt`` or ``*_test.txt`` 
+patterns and processes them as text files containing doctests. 
 This is an experimental feature and likely to change
 its implementation. 
 

Modified: py/dist/py/test/collect.py
==============================================================================
--- py/dist/py/test/collect.py	(original)
+++ py/dist/py/test/collect.py	Sat Jul  8 22:37:12 2006
@@ -223,9 +223,10 @@
 
 class Directory(FSCollector): 
     def filefilter(self, path): 
-        b = path.basename 
+        b = path.purebasename 
         ext = path.ext
-        return b.startswith('test_') and ext in ('.txt', '.py')
+        return (b.startswith('test_') or 
+                b.endswith('_test')) and ext in ('.txt', '.py')
     
     def recfilter(self, path): 
         return path.check(dotfile=0) and \

Modified: py/dist/py/test/testing/test_collect.py
==============================================================================
--- py/dist/py/test/testing/test_collect.py	(original)
+++ py/dist/py/test/testing/test_collect.py	Sat Jul  8 22:37:12 2006
@@ -32,6 +32,18 @@
     assert l[0] == 'test_one' 
     assert l[1] == 'TestClass' 
 
+def test_found_certain_testfiles(): 
+    tmp = py.test.ensuretemp("found_certain_testfiles")
+    tmp.ensure('test_found.py')
+    tmp.ensure('found_test.py')
+
+    colitem = py.test.collect.Directory(tmp) 
+    items = list(colitem.tryiter(py.test.collect.Module))
+    assert len(items) == 2
+    items = [item.name for item in items]
+    assert 'test_found.py' in items
+    assert 'found_test.py' in items
+
 def test_ignored_certain_directories(): 
     tmp = py.test.ensuretemp("ignore_certain_directories")
     tmp.ensure("_darcs", 'test_notfound.py')



More information about the pytest-commit mailing list