pytest-sugar icon indicating copy to clipboard operation
pytest-sugar copied to clipboard

`name` parameter doesn't apply in theme configuration

Open ovunccetin opened this issue 4 months ago • 0 comments

Problem Definition

Theme configuration in pytest-sugar.conf does not apply name parameter.

Example

Configuration file:

[theme]
path=magenta
progressbar=cyan
name=blue

Expected Outcome

All the configuration parameters under theme section must apply.

Actual Outcome

path and progressbar parameters apply (i.e., output colors changed). But the name parameter has no effect and hence the output color is unchanged.

Cause

Starting from the following line, the fields of the Theme class is traversed and the corresponding values read from the configuration.

https://github.com/Teemu/pytest-sugar/blob/efafd9c0d4bfb174db2911beb414bbd4092ffc57/pytest_sugar.py#L144

However, the name field does not have a type annotation (see below line). So, it doesn't returned in the field list of the Theme class. Therefore, it is ignored and not looked up in the configuration.

https://github.com/Teemu/pytest-sugar/blob/efafd9c0d4bfb174db2911beb414bbd4092ffc57/pytest_sugar.py#L51

Solution

Add a type annotation to the name field as follows:

class Theme:
    ...
    name: Optional[str] = None
    ...

ovunccetin avatar Sep 25 '24 14:09 ovunccetin