tweag/FawltyDeps
View on GitHubTests if the generated toml config is loaded correctly as the same `Settings` object: property -based check
Open
#295 opened on Apr 6, 2023
P3good first issuetype: refactoring
Repository metrics
- Stars
- (288 stars)
- PR merge metrics
- (PR metrics pending)
Description
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.