tweag/FawltyDeps
Tests if the generated toml config is loaded correctly as the same `Settings` object: property -based check
Aperta
#295 aperta il 6 apr 2023
P3good first issuetype: refactoring
Metriche repository
- Star
- (288 stelle)
- Metriche merge PR
- (Nessuna PR mergiata in 30 g)
Descrizione
Test if the operation of generating pyproject.toml FawltyDeps section via:
fawltydeps --generate-toml-config
is loaded again gives the same object.
This will be best achieved with the property-based test of function and its inverse. The same may be done for toml settings -> Settings object ->` toml settings check.
Proposed outline of the hypothesis-based test:
generate_settings = strategies.just(Settings()) # here we need to write proper strategies
@given(setting_example=generate_settings)
def test_property__load_printed_config_gives_the_same_object(setting_example, tmp_path):
with open(tmp_path / "pyproject.toml") as f:
print_toml_config(setting_example, out=f)
settings_loaded = Settings.config(config_file=tmp_path / "pyproject.toml").create()
assert setting_example == settings_loaded
It is possible, that refactor of Setting object will be needed or some clever way to use temporary directories in a hypothesis check.