File: test_linked_list.py

package info (click to toggle)
python-mashumaro 3.17-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,408 kB
  • sloc: python: 19,981; sh: 16; makefile: 5
file content (18 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

from mashumaro import DataClassDictMixin


@dataclass
class Node(DataClassDictMixin):
    next: Optional[Node] = None


def test_self_reference():
    assert Node.from_dict({}) == Node()
    assert Node.from_dict({"next": {}}) == Node(Node())
    assert Node().to_dict() == {"next": None}
    assert Node(Node()).to_dict() == {"next": {"next": None}}