Screenshoots with pytests amd dataclass fields dynamicaly and literal choices

Take screenshot of full page with Selenium Python with chromedriver

How to capture screenshot on test case failure with PyTest

Dataclass argument choices with a default option

from dataclasses import dataclass
from typing import Literal

@dataclass
class Person:
    name: Literal['Eric', 'John', 'Graham', 'Terry'] = 'Eric'

Dynamically add fields to dataclass objects

@dataclass
class X:
    i: int

x = X(i=42)
x.__class__ = make_dataclass('Y', fields=[('s', str)], bases=(X,))
x.s = 'text'

asdict(x)
# {'i': 42, 's': 'text'}

Смотри еще: