def test_frozenset(self): """ L{frozenset} should behave like the expected frozenset interface. """ a = frozenset(['a', 'b']) self.assertRaises(AttributeError, getattr, a, "add") self.assertEquals(list(a), ['a', 'b']) b = frozenset(['r', 's']) d = a.union(b) b = list(d) b.sort() self.assertEquals(b, ['a', 'b', 'r', 's'])
def test_frozenset(self): """ L{frozenset} should behave like the expected frozenset interface. """ a = frozenset(['a', 'b']) self.assertRaises(AttributeError, getattr, a, "add") self.assertEqual(sorted(a), ['a', 'b']) b = frozenset(['r', 's']) d = a.union(b) b = list(d) b.sort() self.assertEqual(b, ['a', 'b', 'r', 's'])
def test_frozenset(self): """ L{frozenset} should behave like the expected frozenset interface. """ a = frozenset(["a", "b"]) self.assertRaises(AttributeError, getattr, a, "add") self.assertEqual(list(a), ["a", "b"]) b = frozenset(["r", "s"]) d = a.union(b) b = list(d) b.sort() self.assertEqual(b, ["a", "b", "r", "s"])
def test_frozensetSecurity(self): """ By default, C{frozenset} objects should be allowed by L{jelly.SecurityOptions}. If not allowed, L{jelly.unjelly} should raise L{jelly.InsecureJelly} when trying to unjelly it. """ inputList = [frozenset([1, 2, 3])] self._testSecurity(inputList, "frozenset")
def test_frozenset(self): """ Jellying C{frozenset} instances and then unjellying the result should produce objects which represent the values of the original inputs. """ inputList = [frozenset([1, 2, 3])] output = jelly.unjelly(jelly.jelly(inputList)) self.assertEquals(inputList, output) self.assertNotIdentical(inputList, output)
def test_frozenset(self): """ Check that a C{frozenset} can contain a circular reference and be serializeserialized without losing the reference. """ a = SimpleJellyTest(None, None) s = frozenset([a]) a.x = s res = jelly.unjelly(jelly.jelly(a)) self.assertIsInstance(res.x, frozenset) self.assertEquals(list(res.x), [res])
def test_oldImmutableSets(self): """ Test jellying C{sets.ImmutableSet}: it should serialize to the same thing as C{frozenset} jelly, and be unjellied as C{frozenset} if available. """ inputList = [jelly._sets.ImmutableSet([1, 2, 3])] inputJelly = jelly.jelly(inputList) self.assertEquals(inputJelly, jelly.jelly([frozenset([1, 2, 3])])) output = jelly.unjelly(inputJelly) # Even if the class is different, it should coerce to the same list self.assertEquals(list(inputList[0]), list(output[0])) if frozenset is jelly._sets.ImmutableSet: self.assertIsInstance(output[0], jelly._sets.ImmutableSet) else: self.assertIsInstance(output[0], frozenset)