Since Python 3.13 the compiler now strips common leading whitespace from every line in a docstring. So this have to be fixed in the pytests.
This commit is contained in:
parent
a2a6be536f
commit
f01246ae82
1 changed files with 17 additions and 9 deletions
|
|
@ -2,9 +2,11 @@
|
|||
# pyright: strict
|
||||
import dataclasses
|
||||
import enum
|
||||
import textwrap
|
||||
import typing as t
|
||||
|
||||
import construct as cs
|
||||
|
||||
import construct_typed as cst
|
||||
from construct_typed import DataclassBitStruct, DataclassMixin, DataclassStruct, csfield
|
||||
|
||||
|
|
@ -72,16 +74,20 @@ def test_dataclass_str_repr() -> None:
|
|||
== "Image: \n signature = b'BMP' (total 3)\n width = 3\n height = 2"
|
||||
)
|
||||
|
||||
|
||||
def test_dataclass_ifthenelse() -> None:
|
||||
@dataclasses.dataclass
|
||||
class IfThenElseTest(DataclassMixin):
|
||||
test_if: t.Optional[int] = csfield(cs.If(False, cs.Int8ub))
|
||||
test_ifthenelse: t.Optional[int] = csfield(cs.IfThenElse(True, cs.Int8ub, cs.Pass))
|
||||
test_ifthenelse: t.Optional[int] = csfield(
|
||||
cs.IfThenElse(True, cs.Int8ub, cs.Pass)
|
||||
)
|
||||
|
||||
a = IfThenElseTest(test_if=None, test_ifthenelse=None)
|
||||
assert a.test_if == None
|
||||
assert a.test_ifthenelse == None
|
||||
|
||||
|
||||
def test_dataclass_struct() -> None:
|
||||
@dataclasses.dataclass
|
||||
class Image(DataclassMixin):
|
||||
|
|
@ -395,9 +401,10 @@ def test_tenum_no_enumbase() -> None:
|
|||
|
||||
def test_tenum_asdict() -> None:
|
||||
# see: https://github.com/timrid/construct-typing/issues/21
|
||||
import construct_typed as cst
|
||||
import dataclasses
|
||||
|
||||
import construct_typed as cst
|
||||
|
||||
class TestEnum(cst.EnumBase):
|
||||
one = 1
|
||||
two = 2
|
||||
|
|
@ -436,9 +443,9 @@ def test_tenum_docstring() -> None:
|
|||
Value_NoDoc = cst.EnumValue(2)
|
||||
Value_NoDoc2 = 3
|
||||
|
||||
assert (
|
||||
TestEnum.__doc__
|
||||
== """
|
||||
assert TestEnum.__doc__ is not None
|
||||
assert textwrap.dedent(TestEnum.__doc__) == textwrap.dedent(
|
||||
"""
|
||||
This is an test enum.
|
||||
"""
|
||||
)
|
||||
|
|
@ -508,9 +515,10 @@ def test_tenum_flags() -> None:
|
|||
|
||||
|
||||
def test_tenum_flags_asdict() -> None:
|
||||
import construct_typed as cst
|
||||
import dataclasses
|
||||
|
||||
import construct_typed as cst
|
||||
|
||||
class TestEnum(cst.FlagsEnumBase):
|
||||
one = 1
|
||||
two = 2
|
||||
|
|
@ -549,9 +557,9 @@ def test_tenum_flags_docstring() -> None:
|
|||
Value_NoDoc = cst.EnumValue(2)
|
||||
Value_NoDoc2 = 4
|
||||
|
||||
assert (
|
||||
TestEnum.__doc__
|
||||
== """
|
||||
assert TestEnum.__doc__ is not None
|
||||
assert textwrap.dedent(TestEnum.__doc__) == textwrap.dedent(
|
||||
"""
|
||||
This is an test flags enum.
|
||||
"""
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue