Skip to content

Commit

Permalink
drop support to "should.matcher" syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigomanhaes committed Dec 8, 2010
1 parent 15096f6 commit 66e2f9d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 39 deletions.
13 changes: 0 additions & 13 deletions README.rst
Expand Up @@ -40,16 +40,3 @@ A nice example of exceptions would be::
... ...
ShouldNotSatisfied: 'should' does include 'oul' ShouldNotSatisfied: 'should' does include 'oul'




All Should-DSL releases **before 2.0** uses a deprecated style, although we still support this old style, it will be dropped soon and we discourage you to use that style. Old style usage like::

>>> 3 |should_not.equal_to| 2.99

should be written as::

>>> 3 |should_not| equal_to(2.99)


This new syntax for writing expectations has been changed because the requirement to have a single "right value" had been a limition to write new matchers and add other enhancements to Should-DSL and you should update the code that uses old style, because we plan to remove them soon.

2 changes: 1 addition & 1 deletion should_dsl/doctests/deprecated.txt
Expand Up @@ -4,5 +4,5 @@
>>> @matcher >>> @matcher
... def be_the_square_root_of(): ... def be_the_square_root_of():
... return (lambda x, y: x == math.sqrt(y), "%s is %sthe square root of %s") ... return (lambda x, y: x == math.sqrt(y), "%s is %sthe square root of %s")
>>> 3 |should.be_the_square_root_of| 9 >>> 3 |should| be_the_square_root_of(9)


6 changes: 6 additions & 0 deletions should_dsl/doctests/drop_deprecated_features.txt
Expand Up @@ -21,3 +21,9 @@ Traceback (most recent call last):
... ...
NameError: name 'should_not_have' is not defined NameError: name 'should_not_have' is not defined



>>> "Brasil" |should.end_with| "sil"
Traceback (most recent call last):
...
AttributeError: ...

7 changes: 0 additions & 7 deletions should_dsl/doctests/missing_method.txt

This file was deleted.

18 changes: 0 additions & 18 deletions should_dsl/dsl.py
Expand Up @@ -137,24 +137,6 @@ def _put_predicate_matchers_on_namespace(self):
def _get_all_public_attr_names(self, obj): def _get_all_public_attr_names(self, obj):
return [attr_name for attr_name in dir(obj) if not attr_name.startswith('_')] return [attr_name for attr_name in dir(obj) if not attr_name.startswith('_')]


# deprecated behaviour
def __getattr__(self, method_name):
if method_name not in self._matchers_by_name:
raise AttributeError("%s object has no matcher '%s'" % (
self.__class__.__name__, method_name))
return self._prepare_to_receive_rvalue(method_name)

def _prepare_to_receive_rvalue(self, method_name):
should = Should(negate=self._negate)
should._matchers_by_name = self._matchers_by_name
should._old_style_call = True
should._matcher = self._matchers_by_name[method_name]
return should

def _convert_deprecated_style(self, rvalue):
self._rvalue = self._matcher()
self._rvalue.arg = rvalue



class _PredicateMatcher(object): class _PredicateMatcher(object):


Expand Down

0 comments on commit 66e2f9d

Please sign in to comment.