Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
Make attribute public for test_namespaces.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwchase committed Jul 16, 2017
1 parent 99033cc commit 483f298
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/class_namespaces/namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ class _NamespaceScope(collections.abc.MutableMapping):

"""The class creation namespace for NamespaceableMetas."""

__slots__ = '_dicts', 'namespaces', 'proxies', 'scope_proxy', 'finalized'
__slots__ = 'dicts', 'namespaces', 'proxies', 'scope_proxy', 'finalized'

def __init__(self, dct):
self._dicts = [dct]
self.dicts = [dct]
self.namespaces = []
self.proxies = weakref.WeakKeyDictionary()
self.finalized = False
Expand All @@ -369,11 +369,11 @@ def __init__(self, dct):
@property
def head(self):
"""Return the innermost Namespace scope."""
return self._dicts[0]
return self.dicts[0]

def finalize(self):
"""Mark the scope as no longer active, and return the head."""
if len(self._dicts) != 1:
if len(self.dicts) != 1:
raise ValueError('Cannot finalize a pushed scope!')
self.finalized = True
return self.head
Expand All @@ -382,13 +382,13 @@ def push(self, dct):
"""Add a new active Namespace to the scope."""
if self.finalized:
raise ValueError('Cannot push a finalized scope!')
self._dicts.insert(0, dct)
self.dicts.insert(0, dct)

def pop_(self):
"""Remove the current active Namespace from the scope."""
if len(self._dicts) == 1:
if len(self.dicts) == 1:
raise ValueError('Cannot pop from a basal scope!')
self._dicts.pop(0)
self.dicts.pop(0)

def _raw_get(self, parent, key):
"""Return the item under the given path, without wrapping."""
Expand Down Expand Up @@ -420,15 +420,15 @@ def __getitem__(self, key):
else:
value = self.head[key]
else:
value = collections.ChainMap(*self._dicts)[key]
value = collections.ChainMap(*self.dicts)[key]
return self.wrap(value)

def _store(self, key, value, dct):
"""Return the rebased value and target dict."""
# We just entered the context successfully.
if not self.finalized:
if value is dct:
dct = self._dicts[1]
dct = self.dicts[1]
if isinstance(value, Namespace):
value.push(key, self, dct)
if isinstance(value, self.scope_proxy):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_namespaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_ns(namespace_):
def scope_dicts_length_equals(namespace_, length):
"""Check the length of the associated namespace's scope."""
scope = get_ns(namespace_).scope
assert len(scope._dicts) == length
assert len(scope.dicts) == length


def test_finalization(namespaceable, namespace):
Expand Down

0 comments on commit 483f298

Please sign in to comment.