[Checkins] SVN: z3c.testsetup/trunk/ Fixed some tests on windows, mostly because of path separator issues
Adam Groszer
agroszer at gmail.com
Wed Aug 25 04:43:14 EDT 2010
Log message for revision 115939:
Fixed some tests on windows, mostly because of path separator issues
Changed:
U z3c.testsetup/trunk/CHANGES.txt
_U z3c.testsetup/trunk/src/
U z3c.testsetup/trunk/src/z3c/testsetup/functional/functionaldoctestsetup.txt
U z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py
-=-
Modified: z3c.testsetup/trunk/CHANGES.txt
===================================================================
--- z3c.testsetup/trunk/CHANGES.txt 2010-08-25 08:04:53 UTC (rev 115938)
+++ z3c.testsetup/trunk/CHANGES.txt 2010-08-25 08:43:14 UTC (rev 115939)
@@ -4,7 +4,7 @@
0.8.3 (unreleased)
==================
-- No changes yet.
+- Fixed some tests on windows, mostly because of path separator issues
0.8.2 (2010-07-30)
Property changes on: z3c.testsetup/trunk/src
___________________________________________________________________
Added: svn:ignore
+ z3c.testsetup.egg-info
Modified: z3c.testsetup/trunk/src/z3c/testsetup/functional/functionaldoctestsetup.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/functional/functionaldoctestsetup.txt 2010-08-25 08:04:53 UTC (rev 115938)
+++ z3c.testsetup/trunk/src/z3c/testsetup/functional/functionaldoctestsetup.txt 2010-08-25 08:43:14 UTC (rev 115939)
@@ -65,7 +65,7 @@
>>> from z3c.testsetup.tests import cave
>>> setup = FunctionalDocTestSetup(cave)
>>> setup
- <z3c.testsetup....doctesting.FunctionalDocTestSetup object at 0x...>
+ <z3c.testsetup....doctesting.FunctionalDocTestSetup object at 0x...>
This setup is ready for use::
@@ -144,7 +144,7 @@
* The setup-instance's ``tearDown``-method is set as the ``tearDown``
function.
-
+
>>> setup.setUp
<bound method FunctionalDocTestSetup.setUp of
<z3c.testsetup....doctesting.FunctionalDocTestSetup object at 0x...>>
@@ -187,7 +187,7 @@
>>> import re
>>> from zope.testing import renormalizing
>>> mychecker = renormalizing.RENormalizing([
- ... (re.compile('[0-9]*[.][0-9]* seconds'),
+ ... (re.compile('[0-9]*[.][0-9]* seconds'),
... '<SOME NUMBER OF> seconds'),
... (re.compile('at 0x[0-9a-f]+'), 'at <SOME ADDRESS>'),
... ])
@@ -276,7 +276,7 @@
>>> setup.regexs
[<_sre.SRE_Pattern object at ...>]
-
+
If you need more complex checks here, you can derive your customized
test setup class and overwrite ``isTestFile()``.
@@ -347,13 +347,13 @@
>>> import re
>>> from zope.testing import renormalizing
>>> mychecker = renormalizing.RENormalizing([
- ... (re.compile('[0-9]*[.][0-9]* seconds'),
+ ... (re.compile('[0-9]*[.][0-9]* seconds'),
... '<SOME NUMBER OF> seconds'),
... (re.compile('at 0x[0-9a-f]+'), 'at <SOME ADDRESS>') ])
Then, a setup with this checker can be created::
- >>> mysetup = FunctionalDocTestSetup(cave, checker = mychecker)
+ >>> mysetup = FunctionalDocTestSetup(cave, checker = mychecker)
>>> mysetup.checker
<zope.testing.renormalizing.RENormalizing instance at 0x...>
@@ -401,14 +401,14 @@
>>> from z3c.testsetup.tests import cave_to_let
>>> setup = FunctionalDocTestSetup(cave_to_let)
- >>> pnorm(setup.layer.config_file)
+ >>> setup.layer.config_file
'.../tests/cave_to_let/ftesting.zcml'
The fallback-solution is to take the layer from the
`z3c.testsetup` package::
>>> setup = FunctionalDocTestSetup(cave)
- >>> pnorm(setup.layer.config_file)
+ >>> setup.layer.config_file
'...z3c/testsetup/functional/ftesting.zcml'
Now the fallback `ftesting.zcml` was taken, because the cave got
@@ -454,12 +454,12 @@
>>> setup_w_custom_layer = FunctionalDocTestSetup(
... cave,
... zcml_config = 'sampleftesting.zcml')
- >>> pnorm(setup_w_custom_layer.layer.config_file)
+ >>> setup_w_custom_layer.layer.config_file
'.../tests/cave/sampleftesting.zcml'
You can also pass a keyword parameter `layer`, which should provide a
value with a ready-to-use ZCML layer. If this happens, the
-`zcml_config` and `layer_name` parameter will have no effect.
+`zcml_config` and `layer_name` parameter will have no effect.
To show this, we first create a custom layer::
@@ -478,7 +478,7 @@
... cave,
... zcml_config = 'sampleftesting.zcml',
... layer = mylayer)
- >>> pnorm(setup_w_custom_layer.layer.config_file)
+ >>> setup_w_custom_layer.layer.config_file
'.../testsetup/functional/ftesting.zcml'
As we can see, the `mylayer` config file is registered and the
Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py 2010-08-25 08:04:53 UTC (rev 115938)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py 2010-08-25 08:43:14 UTC (rev 115939)
@@ -26,16 +26,16 @@
# Our own one to work around
# http://reinout.vanrees.org/weblog/2009/07/16/invisible-test-diff.html:
(re.compile(r'.*1034h'), ''),
+ #windows line endings:
+ (re.compile('\r\n'), '\n'),
+ #windows drive root:
+ (re.compile(r'[a-zA-Z]:\\'), '/'),
+ #windows path separator:
+ (re.compile(r'\\\\'), '/'),
+ (re.compile(r'\\'), '/'),
])
-def pnorm(path):
- """Normalization of paths to use forward slashes. This is needed
- to make sure the tests work on windows.
- """
- return path.replace(os.sep, '/')
-
-
def get_testcases_from_suite(suite):
result=[]
for elem in list(suite):
@@ -168,8 +168,7 @@
package = 'z3c.testsetup',
setUp=setUpZope,
tearDown=cleanUpZope,
- globs={'pnorm': pnorm,
- 'get_basenames_from_suite':
+ globs={'get_basenames_from_suite':
get_basenames_from_suite,
'print_file': print_file},
checker=checker,
More information about the checkins
mailing list