I'm writing a Tree class, which should behave a lot like a dictionary.
In order to test this, I took the unittest from the source distribution
for dictionaries and used it to test against my Tree class.
Things are working out rather well, but I stumbled on a problem.
this unittest tries to test for '==' and '<' operators. However I
couldn't find anything in the documentation that defined how
dictionaries should behave with respect to these operators.
For the moment the best I can come up with is something like
the following:
class Tree:
def __lt__(self, term):
return set(self.iterit ems()) < set(term.iterit ems())
def __eq__(self, term):
return set(self.iterit ems()) == set(term.iterit ems())
Would this be a correct definition of the desired behaviour?
Anyone a reference?
--
Antoon Pardon
In order to test this, I took the unittest from the source distribution
for dictionaries and used it to test against my Tree class.
Things are working out rather well, but I stumbled on a problem.
this unittest tries to test for '==' and '<' operators. However I
couldn't find anything in the documentation that defined how
dictionaries should behave with respect to these operators.
For the moment the best I can come up with is something like
the following:
class Tree:
def __lt__(self, term):
return set(self.iterit ems()) < set(term.iterit ems())
def __eq__(self, term):
return set(self.iterit ems()) == set(term.iterit ems())
Would this be a correct definition of the desired behaviour?
Anyone a reference?
--
Antoon Pardon
Comment