Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow monkey patching of methods already implemented by sure #19

Closed
gabrielfalcao opened this issue Nov 8, 2012 · 4 comments · Fixed by #119
Closed

Allow monkey patching of methods already implemented by sure #19

gabrielfalcao opened this issue Nov 8, 2012 · 4 comments · Fixed by #119

Comments

@gabrielfalcao
Copy link
Owner

Sure should allow overwritting the do, does and all the other methods (see below) when using the CPython-compatible syntax sugar (i.e.: (1).should.be.an(int))

  • do
  • do_not
  • does
  • does_not
  • doesnt
  • should
  • should_not
  • shouldnt
  • must

For instance, this test should pass:

import sure

class Foo(object):
    pass

instance = Foo()
instance.do = "anything"
@ghost ghost assigned clarete Nov 8, 2012
@clarete
Copy link
Collaborator

clarete commented Nov 16, 2012

So, currently, we can't do that cause the AssertionBuilder class is attached to all the object() instances as a property. And python does not like to get it's properties overwritten. Maybe we could come up with a helper method. Is it enough?

@gabrielfalcao
Copy link
Owner Author

oh, so you're saying that if the implementation wasn't through @property, we could overwrite the attributes?

@clarete
Copy link
Collaborator

clarete commented Nov 16, 2012

Yes, I think so. But I'm afraid that we need that to use properties! I'll double check to be sure

@timofurrer
Copy link
Collaborator

timofurrer commented Jun 16, 2016

oh, so you're saying that if the implementation wasn't through @property, we could overwrite the attributes?

Yes, that's true.
@clarete Do you remember what you meant by:

Maybe we could come up with a helper method. Is it enough?

I think that this issue could be related to #74 and maybe #44 (didn't had a look at this one yet) as well.

@timofurrer timofurrer added the bug label Jun 16, 2016
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 21, 2016
…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.
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 21, 2016
…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.
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 21, 2016
…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.
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 21, 2016
…lfalcao#19, gabrielfalcao#74

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.
@timofurrer timofurrer modified the milestone: 1.4.0 Jun 21, 2016
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 22, 2016
…lfalcao#19, gabrielfalcao#74

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.
timofurrer added a commit to timofurrer/sure that referenced this issue Jun 22, 2016
…lfalcao#19, gabrielfalcao#74

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.
timofurrer added a commit that referenced this issue Jun 22, 2016
Allow overwriting of monkey-patched properties by sure. Closes #19, #74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants