This is about some small test utils I'm writing for transform code. I'd
like some advice in structuring it before attempting to submit patches...
Questions:
Is it ok to put doctests in Cython sources? I haven't seen anything so
I'm wondering whether you have a policy on it or not.
The tests I have are kind of "unit-test" based, more isolated than the
tests going in the tests directory (in particular, they abort
compilation right after the transform I'm testing, i.e. long before C
serialization).
Is it ok if I just:
- Have a Cython/Testing directory for the test utils...
- Have a Transforms directory in Cython/Compiler containing transforms
- Have doctests directly in module docstrings in
Cython/Compiler/Transforms?
Background:
Basically, I now have the following running in my ForInOptimizations.py [1]:
if __name__ == "__main__":
from Cython.Testing.PipelineTesting import test_transform
t = ForInOptimizations()
test_transform("parsed", t, code = u"""
for idx, value in enumerate(iterable):
print idx, value
""", expected = u"""
idx = 0
for value in iterable:
print idx, value
idx += 1
""")
This test-case is now running successfully, but placing the tests in a
main section like that is perhaps not ideal?
(In case you are wondering what is going on; yes, I am reserializing the
modified parse tree to Python code. It's not difficult to do and allows
for very easy, isolated tests -- though I won't go the entire way to
full unit-testing).
[1]: The ForInOptimizations.py only handles enumerate -- I don't think I
will submit it before phase seperation is in place, because it doesn't
look like I can know whether I should insert a check for int overflow
before then, nor whether enumerate really is __builtin__.enumerate.
But I hope I'll have the the test framework accepted.
--
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev