mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #25665: Make NamedTuple picklable.
This commit is contained in:
parent
05e3090e3a
commit
557d1eb0f3
2 changed files with 13 additions and 0 deletions
|
@ -1163,6 +1163,14 @@ class NamedTupleTests(TestCase):
|
|||
assert Emp._fields == ('name', 'id')
|
||||
assert Emp._field_types == dict(name=str, id=int)
|
||||
|
||||
def test_pickle(self):
|
||||
global Emp # pickle wants to reference the class by name
|
||||
Emp = NamedTuple('Emp', [('name', str), ('id', int)])
|
||||
jane = Emp('jane', 37)
|
||||
z = pickle.dumps(jane)
|
||||
jane2 = pickle.loads(z)
|
||||
assert jane == jane2
|
||||
|
||||
|
||||
class IOTests(TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue