def test_lhs(self):
     p = pred.P(4)
     f = lambda x: x()
     self.assertTrue(f(p > 2))
     self.assertFalse(f(p < 2))
     self.assertTrue(f(p >= 4))
     self.assertTrue(f(p <= 4))
     self.assertFalse(f(p != 4))
     self.assertTrue(f(p != 3))
     # verify for a string too
     p = pred.P('hello')
     self.assertTrue(f(p == 'hello'))
     self.assertFalse(f(p == 'goodbye'))
     self.assertTrue(f(p != 'goodbye'))
 def test_rhs(self):
     p = pred.P(4)
     f = lambda x: x()
     self.assertTrue(f(2 < p))
     self.assertFalse(f(2 > p))
     self.assertTrue(f(4 <= p))
     self.assertTrue(f(4 >= p))
     self.assertFalse(f(4 != p))
     self.assertTrue(f(3 != p))
     # verify for a string too
     p = pred.P('hello')
     self.assertTrue(f('hello' == p))
     self.assertFalse(f('goodbye' == p))
     self.assertTrue(f('goodbye' != p))
 def test_repr(self):
     self.assertEqual(repr(pred.P(4)), 'P(item=4)')
     self.assertEqual(repr(pred.P('hello')), "P(item='hello')")
 def test_str(self):
     self.assertEqual(str(pred.P(4)), '4')
     self.assertEqual(str(pred.P('hello')), 'hello')
 def test_returns_callable(self):
     x = pred.P(4) > 2
     self.assertIsInstance(x, pred.Callable)