Skip to content

Commit

Permalink
Fix newly-introduced bug in Maybe, add test for that and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
pupssman committed Dec 4, 2014
1 parent 558e620 commit 355a098
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 5 additions & 3 deletions builders/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,11 @@ def __init__(self, construct, enabled=False):
self.default = enabled

def doBuild(self, *args, **kwargs):
if self.enabled:
return self.construct.doBuild(*args, **kwargs)
self.enabled = self.default
try:
if self.enabled:
return self.construct.doBuild(*args, **kwargs)
finally:
self.enabled = self.default


class Uplink(Construct):
Expand Down
2 changes: 1 addition & 1 deletion builders/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
@author: pupssman
'''

__version__ = '1.2.6'
__version__ = '1.2.7'
__package_name__ = 'builders'
14 changes: 14 additions & 0 deletions builders/tests/test_modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,17 @@ class B:

assert b1.a is None
assert b2.a


def test_maybe_enabled():
class A:
pass

class B:
a = Maybe(Unique(A))

b1 = Builder(B).withA(Enabled(B.a)).build()
b2 = Builder(B).build()

assert b1.a is not None
assert b2.a is None

0 comments on commit 355a098

Please sign in to comment.