sixty-north / cosmic-ray

Mutation testing for Python
MIT License
556 stars 54 forks source link

Fix configuration loading for OperatorsFilter #504

Closed XD-DENG closed 4 years ago

XD-DENG commented 4 years ago

I may be wrong, but based on

here we should have config.sub('operators-filter') rather than config.sub('filters', 'operators-filter').

Code to Reproduce & Check

If I save the sample configuration TOML in the documentation as config.toml, then I run code below

from cosmic_ray.config import load_config
load_config('config.toml').sub('filters', 'operators-filter')

I got {}.

Instead, if I change to

load_config("config.toml").sub('operators-filter')

I got expected result

{'exclude-operators': ['core/ReplaceComparisonOperator_Is(Not)?_(Not)?(Eq|[LG]tE?)', 'core/ReplaceComparisonOperator_(Not)?(Eq|[LG]tE?)_Is(Not)?', 'core/ReplaceComparisonOperator_[LG]tE_Eq', 'core/ReplaceComparisonOperator_[LG]t_NotEq']}
XD-DENG commented 4 years ago

Of course everything would work fine if we have configuration file

[cosmic-ray.filters.operators-filter]
exclude-operators = [ ... ]

instead of (what is suggested in doc now)

[cosmic-ray.operators-filter]
exclude-operators = [ ... ]

Hence we should either change the code or "correct" the documentation. Otherwise it's really confusing to users.

Any preference?

abingham commented 4 years ago

Thanks for pointing this out!

The correct configuration key is:

[cosmic-ray.filters.operators-filter]

The reason is that the notion of "filter" covers a lot of functionality and different programs. So my plan is to have the "filter" key contain configuration for all filter programs.

I'll make the necessary changes to the documentation, and I'll close this PR without merging it. Thanks again!

XD-DENG commented 4 years ago

Thanks @abingham for the clarification. Definitely reasonable to me.

Cheers!