Skip to content

Commit

Permalink
Write test for AttributeError for module.__file__.
Browse files Browse the repository at this point in the history
Issue #6.
  • Loading branch information
mauritsvanrees committed Feb 27, 2019
1 parent 1d559ef commit f0757a5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/z3c/autoinclude/dependency.txt
Expand Up @@ -155,3 +155,24 @@ Note that it will not catch DistributionNotFound errors::
Traceback (most recent call last):
...
DistributionNotFound: ...

We do not want to break when there are problems with some dependencies.
If a dependency is not found or is not a module, we should not try to load its zcml.
See https://github.com/zopefoundation/z3c.autoinclude/issues/6.
This is easiest to test by some hacking.

>>> from z3c.autoinclude.utils import DistributionManager
>>> DistributionManager.orig_dottedNames = DistributionManager.dottedNames
>>> def dottedNames(self):
... result = self.orig_dottedNames()
... result.extend(['z3c.autoinclude.tests.empty', 'nosuchpackage'])
... return result
>>> DistributionManager.dottedNames = dottedNames
>>> pprint(b_include_finder.includableInfo(['configure.zcml',
... 'meta.zcml']))
{'configure.zcml': ['F.H'], 'meta.zcml': ['testdirective', 'F.G', 'F.H']}

Restore the original dottedNames method:

>>> DistributionManager.dottedNames = DistributionManager.orig_dottedNames
>>> del DistributionManager.orig_dottedNames

0 comments on commit f0757a5

Please sign in to comment.