diff options
author | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2011-09-06 14:24:11 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polyconseil.fr> | 2011-09-06 14:24:11 +0200 |
commit | fc2ee21374aa175521aaf1f164424a24c518c910 (patch) | |
tree | b9bd265c977c9c4ca3f42f3642a749f84f9d22b4 /factory/containers.py | |
parent | 5c770cb1918d8067db69d3c880a9a6ad1d31ddb8 (diff) | |
download | factory-boy-fc2ee21374aa175521aaf1f164424a24c518c910.tar factory-boy-fc2ee21374aa175521aaf1f164424a24c518c910.tar.gz |
Update all tests, and fix a couple of bugs.
Signed-off-by: Raphaël Barrois <raphael.barrois@polyconseil.fr>
Diffstat (limited to 'factory/containers.py')
-rw-r--r-- | factory/containers.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/factory/containers.py b/factory/containers.py index 0620c82..8012444 100644 --- a/factory/containers.py +++ b/factory/containers.py @@ -64,14 +64,14 @@ class OrderedDict(object): if key in self: del self[key] self._values[key] = val - self._order[val.order] = key + self._order.setdefault(val.order, set()).add(key) def __delitem__(self, key): self.pop(key) def pop(self, key): val = self._values.pop(key) - del self._order[val.order] + self._order[val.order].remove(key) return val def items(self): @@ -80,13 +80,14 @@ class OrderedDict(object): def iteritems(self): order = sorted(self._order.keys()) for i in order: - key = self._order[i] - yield (key, self._values[key]) + for key in self._order[i]: + yield (key, self._values[key]) def __iter__(self): order = sorted(self._order.keys()) for i in order: - yield self._order[i] + for k in self._order[i]: + yield k class DeclarationDict(object): @@ -181,7 +182,7 @@ class AttributeBuilder(object): extra = {} self.factory = factory self._attrs = factory.declarations(extra) - self._subfield = self._extract_subfields() + self._subfields = self._extract_subfields() def _extract_subfields(self): sub_fields = {} @@ -198,7 +199,7 @@ class AttributeBuilder(object): attributes = {} for key, val in self._attrs.iteritems(): if isinstance(val, SubFactory): - val = val.evaluate(self.factory, create, self._subfield.get(key, {})) + val = val.evaluate(self.factory, create, self._subfields.get(key, {})) elif isinstance(val, OrderedDeclaration): wrapper = ObjectParamsWrapper(attributes) val = val.evaluate(self.factory, wrapper) |