symonk / asserto

[alpha] Powerful fluent assertions for python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dynamic dispatch: support callables with args

symonk opened this issue · comments

Right now we only support attr_is(expected) for attributes that do not expect any args outside of the instance self; we can do better here.

currently, it ends at instance, self-level, Do you mean you wanted to add the attr_is(expected) further levels of how further lookups happened e.g. ICPO -> instance, class, parent, object

hi @omkarkhatavkar I think right now we support looking up methods on user defined objects via magic on __getattr__ and the is_ idiom, however user defined instances with methods only work if they are called without any args, so it would be nice if we could call for example:

class Foo:
   def do_it(x):
       print(x)
from asserto import assert_that

def test_it():
    assert_that(Foo()).do_it_is(100) # only works if the method has no args.

The naming on methods is obviously lackluster, x_is makes sense for a property lookup (or descriptor etc etc) but not so much for methods.