[Checkins] SVN: Sandbox/ulif/grok-testsetup/src/grok/test Add check
to omit 'hidden' directories.
Uli Fouquet
uli at gnufix.de
Fri Dec 28 04:43:28 EST 2007
Log message for revision 82473:
Add check to omit 'hidden' directories.
Changed:
U Sandbox/ulif/grok-testsetup/src/grok/testing.py
U Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/basicsetup.py
A Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/cave/.hiddendir/
A Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/cave/.hiddendir/hiddenfile.txt
-=-
Modified: Sandbox/ulif/grok-testsetup/src/grok/testing.py
===================================================================
--- Sandbox/ulif/grok-testsetup/src/grok/testing.py 2007-12-27 18:08:52 UTC (rev 82472)
+++ Sandbox/ulif/grok-testsetup/src/grok/testing.py 2007-12-28 09:43:27 UTC (rev 82473)
@@ -64,6 +64,14 @@
return False
return True
+ def isTestDirectory(self, dirpath):
+ """Check whether a given directory should be searched for tests.
+ """
+ if os.path.basename(dirpath).startswith('.'):
+ # We don't search hidden directories like '.svn'
+ return False
+ return True
+
def getDocTestFiles(self, dirpath=None, **kw):
"""Find all doctest files filtered by filter_func.
"""
@@ -77,6 +85,8 @@
dirlist.append(abs_path)
continue
# Search subdirectories...
+ if not self.isTestDirectory(abs_path):
+ continue
subdir_files = self.getDocTestFiles(dirpath=abs_path, **kw)
dirlist.extend(subdir_files)
return dirlist
Modified: Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/basicsetup.py
===================================================================
--- Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/basicsetup.py 2007-12-27 18:08:52 UTC (rev 82472)
+++ Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/basicsetup.py 2007-12-28 09:43:27 UTC (rev 82473)
@@ -83,6 +83,20 @@
>>> file_list
[...'...subdirfile.txt'...]
+Hidden directories, however, are skipped. To check this, we look for a
+'hidden' testfile put into a hidden directory in the `cave`
+directory. We first make sure, that the hidden file really exists::
+
+ >>> cavepath = os.path.dirname(cave.__file__)
+ >>> hiddenpath = os.path.join(cavepath, '.hiddendir', 'hiddenfile.txt')
+ >>> os.path.exists(hiddenpath)
+ True
+
+And now check that it was *not* included in the file list::
+
+ >>> hiddenpath in file_list
+ False
+
To provide a more finegrained filtering, ``BasicTestSetup`` provides a
method ``isTestFile(filepath)``, which returns ``True`` for accepted
files and ``False`` otherwise. This method is called for every file
@@ -109,8 +123,8 @@
False
-How to find another set of files:
----------------------------------
+How to find a customized set of files:
+--------------------------------------
There are several possibilities to modify the search results of
``getDocTestFiles()``. If it is only a matter of filename extension,
@@ -152,7 +166,21 @@
Now also the .TXT file was found, which was omitted in the test
before.
+The set of directories, which are accepted as doctest containers, is
+defined by the ``isTestDirectory`` method, which by default only skips
+'hidden' directories, i.e. directories, that start with a dot ('.').
+ >>> basic_setup3.isTestDirectory('foo/bar/somdir')
+ True
+
+ >>> basic_setup3.isTestDirectory('foo/bar/.hiddendir')
+ False
+
+You can change this behaviour by deriving your own setup class and
+overwriting the method. This works also with derived classes like
+``FunctionalTestSetup``.
+
+
Find terms in docfiles:
-----------------------
Added: Sandbox/ulif/grok-testsetup/src/grok/tests/testsetup/cave/.hiddendir/hiddenfile.txt
===================================================================
More information about the Checkins
mailing list