-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
does green support doctest? #88
Comments
Though I am familiar with the concept of doctests, I have never personally used them or even looked into them. So no, green does not currently support them unless our close ties to the built-in unittest framework brings it in for free. Tell me, how do you usually write/run doctests? Is it part of unittest? Is it part of python? Is it a 3rd-party add-on? I'm curious. |
all right. I am using just built-in doctest. let's say I have a file called # foo.py
class Foo(object):
def bar(sel):
"""
>>> foo = Foo()
>>> foo.bar()
'foobar'
"""
return "foobar" and just run the test
just like that, but as you can see, it's hard to understand the stdard output. |
I think it would be great if you gave it a try! That would be a wonderful feature to add to Green. I wonder if doctest uses unittest under the hood. If it does, that would be a great place to do the integration. |
I never checked out that doctest runs under the unittest, I'll check it out. |
@CleanCut @SamuraiT: It is possible to run doctests with |
I've built a test program to do this:
With unittest, it will run:
So it looks like at some part inside |
Support for doctests was added in version 3.1.0, just released. It requires choosing which modules you want to execute doctests from (for example, lets say you have doctests in # test_stuff.py
import unittest
class TestSomething(unittest.TestCase)
def test_something(self):
# You need to have at least one unittest TestCase subclass with a test method
pass
# Then this will work
import myproj.foo
doctest_modules = [
myproj.foo, # An actual module is best, because then we don't have to "discover" it via the filesystem
"myproj.bar" # But you can indicate the module with a string if you must
] |
Does green support doctest?
I am using doctest, but seems like green does not support doctest.
The text was updated successfully, but these errors were encountered: