Skip to content

Commit 22100e3

Browse files
committed
Fix Literal import in tests
1 parent c5d09c7 commit 22100e3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_code_generation/test_models_code_generator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
from typing import Dict, List, Type, Union
22

33
import pytest
4+
from typing_extensions import Literal
45

56
from json_to_models.dynamic_typing import (AbsoluteModelRef, BaseType, DDict, DList, DOptional, IntString, IsoDateString, ModelMeta, ModelPtr, StringLiteral, StringSerializable, Unknown, compile_imports)
67
from json_to_models.models.base import GenericModelCodeGenerator, generate_code
78
from json_to_models.models.structure import sort_fields
89
from json_to_models.models.utils import indent
910

11+
LITERAL_SOURCE = f"from {Literal.__module__}"
12+
1013
# Data structure:
1114
# (string, indent lvl, indent string)
1215
# result
@@ -305,8 +308,8 @@ def test_unicode(value: ModelMeta, kwargs: dict, expected: str):
305308
"bar": StringLiteral({'bar', 'foo'})
306309
}),
307310
{},
308-
trim("""
309-
from typing_extensions import Literal
311+
trim(f"""
312+
{LITERAL_SOURCE} import Literal
310313
311314
312315
class M:

0 commit comments

Comments
 (0)