forked from gabrielfalcao/sure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overwriting of monkey-patched properties by sure. Closes gabrie…
…lfalcao#19 This allows overwriting of the monkey-patched properties by sure in cpython: ```python from sure import AssertionBuilder class Foo(object): pass instance = Foo() instance.do = "anything" instance.do.should.be.equal("anything") instance2 = Foo() instance2.do.__class__.should.be.equal(AssertionBuilder) ``` This test would pass.
- Loading branch information
1 parent
4b99391
commit 6e350af
Showing
2 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Test fix of bug described in GitHub Issue #19. | ||
""" | ||
|
||
from sure import expect, AssertionBuilder | ||
from sure.magic import is_cpython | ||
|
||
|
||
def test_issue_19(): | ||
"Allow monkey-patching of methods already implemented by sure." | ||
|
||
class Foo(object): | ||
pass | ||
|
||
@property | ||
def should(self): | ||
return 42 | ||
|
||
instance = Foo() | ||
instance.do = "anything" | ||
instance.doesnt = "foo" | ||
|
||
expect(instance.do).should.be.equal("anything") | ||
expect(instance.doesnt).should.be.equal("foo") | ||
|
||
del instance.do | ||
expect(instance.do).shouldnt.be.equal("anything") | ||
|
||
if is_cpython: | ||
instance2 = Foo() | ||
expect(instance2.do).shouldnt.be.equal("anything") | ||
expect(instance.does.__class__).should.be.equal(AssertionBuilder) | ||
|
||
expect(instance.should).should.be.equal(42) |