Beispiel #1
0
    def test_hash_improper_list(self):
        input = Map({
            ImproperList([1, 2, 3], 1000): b"xxx"
        })

        self.assertEquals(
            (input, ""),
            decode(encode(input))
        )

        self.assertEquals(
            input[ImproperList([1, 2, 3], 1000)], b"xxx")
Beispiel #2
0
 def test_comparison(self):
     improper = ImproperList([1, 2, 3], "tail")
     self.assertEqual(improper, improper)
     self.assertEqual(improper, ImproperList([1, 2, 3], "tail"))
     self.assertNotEqual(improper, ImproperList([1, 2, 3], "tail2"))
     self.assertNotEqual(improper, ImproperList([1, 2], "tail"))
Beispiel #3
0
 def test_improper_list(self):
     improper = ImproperList([1, 2, 3], "tail")
     self.assertEqual(ImproperList, type(improper))
     self.assertEqual([1, 2, 3], list(improper))
     self.assertEqual("tail", improper.tail)
     self.assertEqual("ImproperList([1, 2, 3], 'tail')", repr(improper))
Beispiel #4
0
 def test_encode_improper_list(self):
     self.assertEqual("\x83l\0\0\0\1h\0h\0", encode(ImproperList([()], ())))
     self.assertEqual("\x83l\0\0\0\1a\0a\1", encode(ImproperList([0], 1)))
Beispiel #5
0
 def test_immutable(self):
     m = ImproperList([1, 2, 3], 100)
     self.assertRaises(MutationError, m.append, 1)
     self.assertRaises(MutationError, setattr, m, "x", 1)