easiest way to explain this one:
import unittest
from element import Element
class TestHTMLGen(unittest.TestCase):
def test_Element(self):
page = Element("html", el_id=False)
self.assertEqual(page, Element("html", el_id=False)) # this is where I need help
I get the following error:
AssertionError: <element.Element object at 0x025C1B70> != <element.Element object at 0x025C1CB0>
I know the objects are not exactly the same but is there any way to check that they are equal? I would think that assertEqual would work.
edit: I am working with the addTypeEqualityFunc. However, I am still having trouble
def test_Element(self):
page = Element("html", el_id=False)
self.addTypeEqualityFunc(Element, self.are_elements_equal)
self.assertEqual(page, Element("html", el_id=False))
def are_elements_equal(self, first_element, second_element, msg=None):
print first_element.attribute == second_element.attribute
return type(first_element) is type(second_element) and first_element.tag == second_element.tag and first_element.attribute == second_element.attribute
This is the output I get:
False
and it says the test passed. It should not pass because first_element.attribute is not equal to second_element.attribute. Furthermore, even if I just have return false
for are_elements_equal
, the test still passes.