- with self.assertRaises(TypeError):
- op(self._def, A())
-
- def _test_binop_invalid_none(self, op):
- if op in _COMP_BINOPS:
- self.skipTest('not testing')
-
- with self.assertRaises(TypeError):
- op(self._def, None)
+ # Operators == and != are defined when comparing the field to an
+ # arbitrary object.
+ if op is operator.eq:
+ self.assertIs(op(self._def, A()), False)
+ elif op is operator.ne:
+ self.assertIs(op(self._def, A()), True)
+ else:
+ # But not other operators.
+ with self.assertRaises(TypeError):
+ op(self._def, A())
+
+ def _test_binop_none(self, op):
+ # Operators == and != are defined when comparing the field to None.
+ if op is operator.eq:
+ self.assertIs(op(self._def, None), False)
+ elif op is operator.ne:
+ self.assertIs(op(self._def, None), True)
+ else:
+ # But not other operators.
+ with self.assertRaises(TypeError):
+ op(self._def, None)