[Python-checkins] python/dist/src/Lib/test test_doctest3.txt, NONE, 1.1 test_doctest.py, 1.52, 1.53

fdrake at users.sourceforge.net fdrake at users.sourceforge.net
Wed Dec 22 00:46:37 CET 2004


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22743/Lib/test
Modified Files:
	test_doctest.py 
Added Files:
	test_doctest3.txt 
Log Message:
add __file__ to the globals available for tests loaded via DocFileSuite;
this is useful for locating supporting data files, just as it is in Python
modules
--- NEW FILE: test_doctest3.txt ---
Here we check that `__file__` is provided:
 >>> type(__file__)
 <type 'str'>
Index: test_doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_doctest.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- test_doctest.py	8 Nov 2004 22:07:36 -0000	1.52
+++ test_doctest.py	21 Dec 2004 23:46:27 -0000	1.53
@@ -2010,6 +2010,14 @@
 modified the test globals. The test globals are
 automatically cleared for us after a test.
 
+ Tests in a file run using `DocFileSuite` can also access the
+ `__file__` global, which is set to the name of the file
+ containing the tests:
+
+ >>> suite = doctest.DocFileSuite('test_doctest3.txt')
+ >>> suite.run(unittest.TestResult())
+ <unittest.TestResult run=1 errors=0 failures=0>
+
 """
 
 def test_trailing_space_in_test():


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /