From 1799d3ba0d29593235b32f21d259ddbb3b7d31c4 Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 28 Nov 2021 13:05:03 +0000 Subject: [PATCH] conditional test --- tests/test_repr.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/test_repr.py b/tests/test_repr.py index c47b76b1..3c2f48a4 100644 --- a/tests/test_repr.py +++ b/tests/test_repr.py @@ -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)"