mirror of https://github.com/Textualize/rich.git
conditional test
This commit is contained in:
parent
5eafdbcee2
commit
1799d3ba0d
|
@ -1,10 +1,22 @@
|
|||
import pytest
|
||||
import sys
|
||||
from typing import Optional
|
||||
|
||||
from rich.console import Console
|
||||
import rich.repr
|
||||
|
||||
|
||||
skip_py36 = pytest.mark.skipif(
|
||||
sys.version_info.minor == 6 and sys.version_info.major == 3,
|
||||
reason="rendered differently on py3.6",
|
||||
)
|
||||
|
||||
skip_py37 = pytest.mark.skipif(
|
||||
sys.version_info.minor == 7 and sys.version_info.major == 3,
|
||||
reason="rendered differently on py3.7",
|
||||
)
|
||||
|
||||
|
||||
@rich.repr.auto
|
||||
class Foo:
|
||||
def __init__(self, foo: str, bar: Optional[int] = None, egg: int = 1):
|
||||
|
@ -59,13 +71,21 @@ def test_rich_repr() -> None:
|
|||
assert (repr(Foo("hello", bar=3))) == "Foo('hello', 'hello', bar=3, egg=1)"
|
||||
|
||||
|
||||
@skip_py36
|
||||
@skip_py37
|
||||
def test_rich_repr_positional_only() -> None:
|
||||
@rich.repr.auto
|
||||
class PosOnly:
|
||||
def __init__(self, foo, /):
|
||||
self.foo = 1
|
||||
|
||||
p = PosOnly(1)
|
||||
_locals = locals().copy()
|
||||
exec(
|
||||
"""\
|
||||
@rich.repr.auto
|
||||
class PosOnly:
|
||||
def __init__(self, foo, /):
|
||||
self.foo = 1
|
||||
""",
|
||||
globals(),
|
||||
_locals,
|
||||
)
|
||||
p = _locals["PosOnly"](1)
|
||||
assert repr(p) == "PosOnly(1)"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue