Teemu / pytest-sugar

a plugin for py.test that changes the default look and feel of py.test (e.g. progressbar, show tests that fail instantly)
Other
1.3k stars 73 forks source link

`name` parameter doesn't apply in theme configuration #287

Open ovunccetin opened 4 days ago

ovunccetin commented 4 days ago

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
    ...