From 24a6b28adc386a2b50a91877e17afb9538518516 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Wed, 30 Aug 2017 19:01:22 -0400 Subject: [PATCH] MAINT: Fix namedtuple tests. --- tests/cloudpickle_test.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/cloudpickle_test.py b/tests/cloudpickle_test.py index c4f7150d5..ea8b7ba6b 100644 --- a/tests/cloudpickle_test.py +++ b/tests/cloudpickle_test.py @@ -702,13 +702,18 @@ def test_function_module_name(self): self.assertEqual(pickle_depickle(func).__module__, func.__module__) def test_namedtuple(self): - MyTuple = collections.namedtuple('MyTuple', ['a', 'b', 'c']) + MyTuple = collections.namedtuple('MyTuple', ['a', 'b', 'c']) t = MyTuple(1, 2, 3) - depickled_t = pickle_depickle(t) + + depickled_t, depickled_MyTuple = pickle_depickle([t, MyTuple]) + self.assertIsInstance(depickled_t, depickled_MyTuple) self.assertEqual((depickled_t.a, depickled_t.b, depickled_t.c), (1, 2, 3)) - self.assertEqual(vars(t), vars(depickled_t)) + self.assertEqual((depickled_t[0], depickled_t[1], depickled_t[2]), (1, 2, 3)) + + self.assertEqual(depickled_MyTuple.__name__, 'MyTuple') + self.assertTrue(issubclass(depickled_MyTuple, tuple)) if __name__ == '__main__': unittest.main()