Updated
Thank you all for the suggestions, but I'm having a new issue here.
Since I'm comparing two datetime.datetime
objects and I didn't realize that it doesn't have attribute items
or keys
to iterate from, some valid answers provided below no longer work. I'm refactoring my dummy data here to better reflect my use cases,
# Two datetime that I want to assert equal as long as they are equal to the 'second'
now = datetime.datetime(2015, 7, 22, 11, 36, 49, 811000)
then = datetime.datetime(2015, 7, 22, 11, 36, 49, 811099)
assert now == then # this for sure will return false
As you can see from the example, every attribute but 'microsecond' is equal. Anyway to loop through the attributes and compare?
Thanks guys!