Opened 16 years ago
Closed 16 years ago
#7693 closed (invalid)
Different import paths can impact whether doctests are run or not.
Reported by: | Dave Naffziger | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
My directory structure looks like this:
/appname/models.py
/appname/utils/init.py (empty)
/appname/utils/util1.py
in util1.py, I do this:
from appname.models import Class1, Class2
This import causes the doctests in models.py to not run. If I remove util1.py entirely, the doctests in models.py are run.
I patched this by editing line 895 in root/django/trunk/django/test/_doctest.py
I changed it from:
return module.name == object.module
to
return module.name.find(object.module) >=0
In my example above:
module.name = 'appname.models' and
object.module = 'projectname.appname.models'
I'm selecting 'has patch' and attaching the file, but frankly am not sure if this is the right way to handle this or not.
Attachments (1)
Change History (2)
by , 16 years ago
Attachment: | _doctest.py added |
---|
comment:1 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
There must be something else going on here - you haven't mentioned anything that imports util1.py, so that code won't be imported, and therefore wont be executed. I don't deny you're seeing a problem, but either util1.py isn't the cause, or there is something else going on that your instructions don't cover.
Also - regarding your proposed solution - _doctest.py is a copy of the Python version, provided as a workaround for bugs in older Python versions. Patches proposing fixes to _doctest.py are almost certainly not the right solution to any problem - if they are the solution, they should be submitted upstream to Python itself.