#21206: Misleading Exception on emty test class: ImportError: Start directory is
not importable
-----------------------------------+--------------------------------------
     Reporter:  thepapermen        |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  1.6-beta-1
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by carljm):

 Yeah, on a closer look, you're right. Although this error message is
 reproducible with `python -m unittest discover path.to.EmptyTestCase`,
 it's not tied to an empty test case; it's simply because in unittest
 "discover" does not accept dotted paths to test case classes, only file
 paths or dotted package paths to start discovery at. Django's discovery
 runner attempts to combine unittest's discovery ability with its ability
 to load tests directly from a dotted module / testcase path, by
 autodetecting which one each provided test label is, and the bug here lies
 in that autodetection. We assume that if we try `loadTestsFromName` and no
 tests are found, that the given label must have been a package instead,
 and so we try discovery. When the given label was in fact an empty test
 case class, this error occurs.

 In order to fix this, we'll need to do some further checks in the `if not
 (tests and tests.countTestCases())` block to verify that the provided
 label actually maps to a package before we try discovery on it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/21206#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.03d3340c13354b0e15eeb572dd9d78cb%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to