File tree Expand file tree Collapse file tree
packages/google-cloud-monitoring Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,10 +87,12 @@ def _to_dict(self):
8787 return info
8888
8989 def __eq__ (self , other ):
90+ if not isinstance (other , LabelDescriptor ):
91+ return NotImplemented
9092 return self .__dict__ == other .__dict__
9193
9294 def __ne__ (self , other ):
93- return self . __dict__ != other . __dict__
95+ return not self == other
9496
9597 def __repr__ (self ):
9698 return (
Original file line number Diff line number Diff line change 1414
1515import unittest
1616
17+ import mock
18+
1719
1820class TestLabelValueType (unittest .TestCase ):
1921
@@ -108,9 +110,13 @@ def test_equality(self):
108110 KEY = 'response_code'
109111 VALUE_TYPE = 'INT64'
110112 DESCRIPTION = 'HTTP status code for the request.'
111- descriptor1 = self ._make_one (key = KEY , value_type = VALUE_TYPE ,
112- description = DESCRIPTION )
113+ descriptor1a = self ._make_one (key = KEY , value_type = VALUE_TYPE ,
114+ description = DESCRIPTION )
115+ descriptor1b = self ._make_one (key = KEY , value_type = VALUE_TYPE ,
116+ description = DESCRIPTION )
113117 descriptor2 = self ._make_one (key = KEY , value_type = VALUE_TYPE ,
114- description = DESCRIPTION )
115- self .assertTrue (descriptor1 == descriptor2 )
116- self .assertFalse (descriptor1 != descriptor2 )
118+ description = DESCRIPTION + 'foo' )
119+ self .assertEqual (descriptor1a , descriptor1b )
120+ self .assertNotEqual (descriptor1a , descriptor2 )
121+ self .assertNotEqual (descriptor1a , object ())
122+ self .assertEqual (descriptor1a , mock .ANY )
You can’t perform that action at this time.
0 commit comments