Bug 781050: Change equals() to __eq__() to be more idiomatic for python r=jgriffin
authorDavid Burns <dburns@mozilla.com>
Thu, 09 Aug 2012 13:01:56 -0700
changeset 102003 cee342fc2c0d70ade9a6ac353b16943f4a80e128
parent 102002 7ba91b3e9f38f3662f3e2f6f31c2fb36be29dde6
child 102004 afc4105801f9e57967e26ee663609cf15966c679
push id13268
push userdburns@mozilla.com
push dateThu, 09 Aug 2012 20:03:09 +0000
treeherdermozilla-inbound@cee342fc2c0d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs781050
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 781050: Change equals() to __eq__() to be more idiomatic for python r=jgriffin
testing/marionette/client/marionette/marionette.py
testing/marionette/client/marionette/tests/unit/test_findelement.py
--- a/testing/marionette/client/marionette/marionette.py
+++ b/testing/marionette/client/marionette/marionette.py
@@ -24,18 +24,18 @@ class HTMLElement(object):
     def __init__(self, marionette, id):
         self.marionette = marionette
         assert(id is not None)
         self.id = id
 
     def __str__(self):
         return self.id
 
-    def equals(self, other_element):
-        return self.marionette._send_message('elementsEqual', 'value', elements=[self.id, other_element.id])
+    def __eq__(self, other_element):
+        return self.id == other_element.id
 
     def find_element(self, method, target):
         return self.marionette.find_element(method, target, self.id)
 
     def find_elements(self, method, target):
         return self.marionette.find_elements(method, target, self.id)
 
     def get_attribute(self, attribute):
--- a/testing/marionette/client/marionette/tests/unit/test_findelement.py
+++ b/testing/marionette/client/marionette/tests/unit/test_findelement.py
@@ -9,114 +9,114 @@ from errors import NoSuchElementExceptio
 
 class TestElements(MarionetteTestCase):
     def test_id(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
         found_el = self.marionette.find_element("id", "mozLink")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_child_element(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.find_element("id", "divLink")
         div = self.marionette.find_element("id", "testDiv")
         found_el = div.find_element("tag name", "a")
         self.assertEqual("a", found_el.tag_name)
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_child_elements(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.find_element("id", "divLink2")
         div = self.marionette.find_element("id", "testDiv")
         found_els = div.find_elements("tag name", "a")
         self.assertTrue(el.id in [found_el.id for found_el in found_els])
 
     def test_tag_name(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementsByTagName('body')[0];")
         found_el = self.marionette.find_element("tag name", "body")
         self.assertEqual('body', found_el.tag_name)
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("tag name", "body")[0]
         self.assertEqual('body', found_el.tag_name)
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_class_name(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementsByClassName('linkClass')[0];")
         found_el = self.marionette.find_element("class name", "linkClass")
         self.assertEqual(HTMLElement, type(found_el));
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("class name", "linkClass")[0]
         self.assertEqual(HTMLElement, type(found_el));
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_name(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementsByName('myInput')[0];")
         found_el = self.marionette.find_element("name", "myInput")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("name", "myInput")[0]
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
     
     def test_selector(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementById('testh1');")
         found_el = self.marionette.find_element("css selector", "h1")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("css selector", "h1")[0]
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_link_text(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
         found_el = self.marionette.find_element("link text", "Click me!")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("link text", "Click me!")[0]
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_partial_link_text(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
         found_el = self.marionette.find_element("partial link text", "Click m")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("partial link text", "Click m")[0]
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_xpath(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
         found_el = self.marionette.find_element("xpath", "id('mozLink')")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
         found_el = self.marionette.find_elements("xpath", "id('mozLink')")[0]
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_not_found(self):
         test_html = self.marionette.absolute_url("test.html")
         self.marionette.navigate(test_html)
         self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "I'm not on the page")
 
     def test_timeout(self):
         test_html = self.marionette.absolute_url("test.html")
@@ -137,49 +137,49 @@ class TestElementsChrome(MarionetteTestC
         self.marionette.execute_script("window.close();")
         self.marionette.switch_to_window(self.win)
         MarionetteTestCase.tearDown(self)
 
     def test_id(self):
         el = self.marionette.execute_script("return window.document.getElementById('textInput');")
         found_el = self.marionette.find_element("id", "textInput")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_child_element(self):
         el = self.marionette.find_element("id", "textInput")
         parent = self.marionette.find_element("id", "things")
         found_el = parent.find_element("tag name", "textbox")
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_child_elements(self):
         el = self.marionette.find_element("id", "textInput3")
         parent = self.marionette.find_element("id", "things")
         found_els = parent.find_elements("tag name", "textbox")
         self.assertTrue(el.id in [found_el.id for found_el in found_els])
 
     def test_tag_name(self):
         el = self.marionette.execute_script("return window.document.getElementsByTagName('vbox')[0];")
         found_el = self.marionette.find_element("tag name", "vbox")
         self.assertEquals('vbox', found_el.tag_name)
         self.assertEqual(HTMLElement, type(found_el))
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_class_name(self):
         el = self.marionette.execute_script("return window.document.getElementsByClassName('asdf')[0];")
         found_el = self.marionette.find_element("class name", "asdf")
         self.assertEqual(HTMLElement, type(found_el));
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_xpath(self):
         el = self.marionette.execute_script("return window.document.getElementById('testBox');")
         found_el = self.marionette.find_element("xpath", "id('testBox')")
         self.assertEqual(HTMLElement, type(found_el));
-        self.assertEqual(el.id, found_el.id)
+        self.assertEqual(el, found_el)
 
     def test_not_found(self):
         self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "I'm not on the page")
 
 
     def test_timeout(self):
         self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "myid")
         self.assertTrue(True, self.marionette.set_search_timeout(4000))