Commit 63823f71 authored by Jason Madden's avatar Jason Madden Committed by GitHub

Merge pull request #136 from zopefoundation/issue132

Fix __all__
parents f9b05982 2908ae74
......@@ -18,3 +18,4 @@ dist
.eggs/
.dir-locals.el
pip-wheel-metadata/
htmlcov/
......@@ -17,6 +17,14 @@ python:
jobs:
include:
- name: Documentation
python: 3.8
install:
- pip install -U -e .[docs]
script:
- sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
- sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest
after_success:
# Special Linux builds
- name: "Python: 2.7, pure (no C extensions)"
......
......@@ -127,8 +127,15 @@ def populate_module(mod_globals,
from ._base import _fix_pickle
module_name = mod_globals['__name__']
# Define the Python implementations
mod_globals.update(_create_globals(module_name, key_datatype, value_datatype))
# Import the C versions, if possible. Whether or not this is possible,
# this currently makes the non-`Py' suffixed names available. This should change
# if we start defining the Python classes with their natural name, only aliased
# to the 'Py` suffix (which simplifies pickling)
import_c_extension(mod_globals)
# Next, define __all__ after all the name aliasing is done.
# XXX: Maybe derive this from the values we create.
mod_all = (
'Bucket', 'Set', 'BTree', 'TreeSet',
......@@ -143,10 +150,9 @@ def populate_module(mod_globals,
mod_globals['using64bits'] = key_datatype.using64bits or value_datatype.using64bits
import_c_extension(mod_globals)
# XXX: We can probably do better than fix_pickle now;
# we can know if we're going to be renaming classes
# ahead of time.
# ahead of time. See above.
_fix_pickle(mod_globals, module_name)
directlyProvides(module or sys.modules[module_name], interface)
......
......@@ -1972,17 +1972,23 @@ class ModuleTest(object):
value_type = None
def _getModule(self):
pass
def testNames(self):
names = ['Bucket', 'BTree', 'Set', 'TreeSet']
mod = self._getModule()
mod_all = mod.__all__
for name in names:
klass = getattr(self._getModule(), name)
self.assertEqual(klass.__module__, self._getModule().__name__)
self.assertIs(klass, getattr(self._getModule(),
klass = getattr(mod, name)
self.assertEqual(klass.__module__, mod.__name__)
self.assertIs(klass, getattr(mod,
self.prefix + name))
self.assertIn(name, mod_all)
self.assertIn(self.prefix + name, mod_all)
# BBB for zope.app.security ZCML :(
pfx_iter = self.prefix + 'TreeIterator'
klass = getattr(self._getModule(), pfx_iter)
self.assertEqual(klass.__module__, self._getModule().__name__)
klass = getattr(mod, pfx_iter)
self.assertEqual(klass.__module__, mod.__name__)
def testModuleProvides(self):
from zope.interface.verify import verifyObject
......@@ -1998,25 +2004,29 @@ class ModuleTest(object):
elif 'I' in self.prefix:
self.assertTrue(self._getModule().family is BTrees.family32)
def _check_union_presence(self, datatype, name):
mod = self._getModule()
if datatype.supports_value_union():
in_ = self.assertIn
has = self.assertTrue
else:
in_ = self.assertNotIn
has = self.assertFalse
in_(name, dir(mod))
has(hasattr(mod, name))
in_(name, mod.__all__)
# The weighted* functions require the value type to support unions.
def test_weightedUnion_presence(self):
if self.value_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'weightedUnion'))
else:
self.assertFalse(hasattr(self._getModule(), 'weightedUnion'))
self._check_union_presence(self.value_type, 'weightedUnion')
def test_weightedIntersection_presence(self):
if self.value_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'weightedIntersection'))
else:
self.assertFalse(hasattr(self._getModule(), 'weightedIntersection'))
self._check_union_presence(self.value_type, 'weightedIntersection')
# The multiunion function requires the key type to support unions
def test_multiunion_presence(self):
if self.key_type.supports_value_union():
self.assertTrue(hasattr(self._getModule(), 'multiunion'))
else:
self.assertFalse(hasattr(self._getModule(), 'multiunion'))
self._check_union_presence(self.key_type, 'multiunion')
class I_SetsBase(object):
......
......@@ -5,7 +5,9 @@
4.7.1 (unreleased)
==================
- Nothing changed yet.
- Fix the definitions of ``__all__`` in modules. In 4.7.0, they
incorrectly left out names. See `PR 132
<https://github.com/zopefoundation/BTrees/pull/132>`_.
4.7.0 (2020-03-17)
......@@ -23,7 +25,6 @@
consistent between Python 2 and Python 3 and between 32-bit and
64-bit variants.
- Make the Bucket types consistent with the BTree types as updated in
versions 4.3.2: Querying for keys with default comparisons or that
are not integers no longer raises ``TypeError``.
......
......@@ -223,6 +223,7 @@ setup(name='BTrees',
'docs': [
'Sphinx',
'repoze.sphinx.autointerface',
'sphinx_rtd_theme',
],
},
test_suite="BTrees.tests",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment