unit testing Python objects with pytest -
i've method returns list of objects meet criteria
result = find_objects(some_criteria) print("%r" % result) >> [<my_object.my_object object @ 0x85abbcc>]
i write pytest verify operation of find_objects()
def test_finder(testbed): result = testbed.find_objects(some_criteria) assert result [<my_object.my_object object @ 0x85abbcc>]
so far, pytest pointing left angle-bracket (<) , declaring "syntaxerror"
i'm thinking if work, fail in future when 'my_object' stored in location. if have multiple instances, how confirm correct number of them reported?
in context, pythonic way verify output of method returns objects?
js
you can try:
assert isinstance(result, my_object.my_object)
you try comparing on string representation (which you're doing, except missing quotes.) isinstance docs might want take @ repr docs idea of what's happening in print statement. angle brackets mean isn't plug-in replacement object.
Comments
Post a Comment