[Checkins] SVN: z3c.extfile/trunk/src/z3c/extfile/ Added test.py
for simpler use in tests using z3c.extfile
Juergen Kartnaller
juergen at kartnaller.at
Thu Nov 22 07:37:21 EST 2007
Log message for revision 81957:
Added test.py for simpler use in tests using z3c.extfile
Changed:
U z3c.extfile/trunk/src/z3c/extfile/README.txt
A z3c.extfile/trunk/src/z3c/extfile/testing.py
A z3c.extfile/trunk/src/z3c/extfile/testing.txt
U z3c.extfile/trunk/src/z3c/extfile/tests.py
-=-
Modified: z3c.extfile/trunk/src/z3c/extfile/README.txt
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/README.txt 2007-11-22 00:00:51 UTC (rev 81956)
+++ z3c.extfile/trunk/src/z3c/extfile/README.txt 2007-11-22 12:37:20 UTC (rev 81957)
@@ -67,3 +67,12 @@
paste.filter_factory = z3c.extfile.filter:filter_factory
directory = /path/to/hashdir/storage
+
+Testing
+=======
+
+If you use extfile in your testing the you ned to have a storagedir set for
+testing. You can do this by simply importing z3c.extfile.testing in your
+tests.py file. This will set up the environment vaiable to a temporary
+directory during the test.
+
Added: z3c.extfile/trunk/src/z3c/extfile/testing.py
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/testing.py (rev 0)
+++ z3c.extfile/trunk/src/z3c/extfile/testing.py 2007-11-22 12:37:20 UTC (rev 81957)
@@ -0,0 +1,25 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+import os
+import tempfile
+
+# set the extfile directory for testing to a temprary directory
+extfileDir = tempfile.mkdtemp()
+os.environ['EXTFILE_STORAGEDIR'] = tempfile.mkdtemp()
+
Property changes on: z3c.extfile/trunk/src/z3c/extfile/testing.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: z3c.extfile/trunk/src/z3c/extfile/testing.txt
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/testing.txt (rev 0)
+++ z3c.extfile/trunk/src/z3c/extfile/testing.txt 2007-11-22 12:37:20 UTC (rev 81957)
@@ -0,0 +1,23 @@
+===============
+Extfile Testing
+===============
+
+The testing module set the extfile environment vaiable to a temporary
+directory.
+
+ >>> import os
+ >>> if 'EXTFILE_STORAGEDIR' in os.environ:
+ ... oldEnv = os.environ['EXTFILE_STORAGEDIR']
+ ... else:
+ ... oldEnv = 'I am not set'
+
+Simply import
+
+ >>> import z3c.extfile.testing
+
+and we have the environment vaiable set
+
+ >>> import os
+ >>> os.environ['EXTFILE_STORAGEDIR'] == oldEnv
+ False
+
Property changes on: z3c.extfile/trunk/src/z3c/extfile/testing.txt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: z3c.extfile/trunk/src/z3c/extfile/tests.py
===================================================================
--- z3c.extfile/trunk/src/z3c/extfile/tests.py 2007-11-22 00:00:51 UTC (rev 81956)
+++ z3c.extfile/trunk/src/z3c/extfile/tests.py 2007-11-22 12:37:20 UTC (rev 81957)
@@ -1,10 +1,30 @@
+##############################################################################
+#
+# Copyright (c) 2005 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
import doctest
import unittest
+
from zope.testing.doctestunit import DocFileSuite, DocTestSuite
from zope.app.testing import setup
+
def test_suite():
-
+
return unittest.TestSuite(
(
DocFileSuite('hashdir.txt',
@@ -30,6 +50,10 @@
DocTestSuite('z3c.extfile.utility',
optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
),
+ # this needs to be the last test !
+ DocFileSuite('testing.txt',
+ optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
+ ),
))
if __name__ == '__main__':
More information about the Checkins
mailing list