zhilts / mockito-python

Automatically exported from code.google.com/p/mockito-python
0 stars 0 forks source link

Rename any() because it overrides a python builtin #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
any() is a builtin in recent python version (and one that can be very handy to 
have around in test code ;)), thus I think mockito should use a different name 
for this matcher (PEP-8 suggests any_ but that's a bit ugly IMHO). 
Unfortunately, I can't think of anything better right now ;)

Original issue reported on code.google.com by christop...@gmail.com on 5 Aug 2010 at 9:19

GoogleCodeExporter commented 8 years ago
"any" is in matchers package. So if you need to use both builtin any and 
mockitos one you can import matchers package:
from mockito import macthers
# use matchers.any()

Original comment by serhiy%oplakanets.com@gtempaccount.com on 1 Sep 2010 at 9:05

GoogleCodeExporter commented 8 years ago
Couldn't figure out a better name for _any_, so I think using static import:
from mockito import matchers
and using _mathers.any_ instead of _any_ is preferable way. You can, of course, 
renamed imported object:
from mockito.matchers import any as any_
and use _any__ instead of _any_  which will also work. 

Which really should be neccessary only when you need to use both python's and 
mockito's any

Original comment by serhiy%oplakanets.com@gtempaccount.com on 29 Sep 2010 at 7:11