Example #1
0
 def test_dict(self):
     d = {"one": 1, "two": 2, "three": 3}
     for i in (1, 2, 3):
         self.assertTrue(i in py2.dict_values(d))
         self.assertFalse(i in py2.dict_keys(d))
     self.assertFalse("one" in py2.dict_values(d))
     self.assertTrue("one" in py2.dict_keys(d))
     self.assertTrue(("one", 1) in py2.dict_items(d))
     self.assertFalse((1, "one") in py2.dict_items(d))
     # finally, these functions return iterable objects, not lists
     try:
         py2.dict_keys(d)[0]
         self.fail("dict_keys can be indexed")
     except TypeError:
         pass
     try:
         py2.dict_values(d)[0]
         self.fail("dict_values can be indexed")
     except TypeError:
         pass
     try:
         py2.dict_items(d)[0]
         self.fail("dict_items can be indexed")
     except TypeError:
         pass
Example #2
0
 def test_dict(self):
     d = {"one": 1, "two": 2, "three": 3}
     for i in (1, 2, 3):
         self.assertTrue(i in py2.dict_values(d))
         self.assertFalse(i in py2.dict_keys(d))
     self.assertFalse("one" in py2.dict_values(d))
     self.assertTrue("one" in py2.dict_keys(d))
Example #3
0
 def test_dict(self):
     d = {"one": 1, "two": 2, "three": 3}
     for i in (1, 2, 3):
         self.assertTrue(i in py2.dict_values(d))
         self.assertFalse(i in py2.dict_keys(d))
     self.assertFalse("one" in py2.dict_values(d))
     self.assertTrue("one" in py2.dict_keys(d))
     self.assertTrue(("one", 1) in py2.dict_items(d))
     self.assertFalse((1, "one") in py2.dict_items(d))
     # finally, these functions return iterable objects, not lists
     try:
         py2.dict_keys(d)[0]
         self.fail("dict_keys can be indexed")
     except TypeError:
         pass
     try:
         py2.dict_values(d)[0]
         self.fail("dict_values can be indexed")
     except TypeError:
         pass
     try:
         py2.dict_items(d)[0]
         self.fail("dict_items can be indexed")
     except TypeError:
         pass