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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -