#!C:\Python31\python.exe """test_one_and_one.py Created by: Michael Newman Description: Example that shows that assertDictContainsSubset in unittest.Testcase cannot handle error messages that need to show integer keys. """ import unittest class Test_one_and_one(unittest.TestCase): def setUp(self): self.dict_with_mixed_keys = {} self.dict_with_mixed_keys[1] = "numeric key one" self.dict_with_mixed_keys["1"] = "text key one" self.dict_with_mixed_keys["2"] = "two pythons are better than one" self.dict_with_text_keys = {} self.dict_with_text_keys["1"] = "text key one" self.dict_with_text_keys["2"] = "two pythons are better than one" def test_mixed_keys(self): self.assertDictContainsSubset({1: "numeric key one"}, self.dict_with_mixed_keys) def test_text_keys(self): self.assertDictContainsSubset({"1": "text key one"}, self.dict_with_text_keys) def test_mixed_keys_fail(self): self.assertDictContainsSubset({3: "this does not exist"}, self.dict_with_mixed_keys) def test_text_keys_fail(self): self.assertDictContainsSubset({"3": "this does not exist"}, self.dict_with_text_keys) if __name__ == '__main__': unittest.main()