Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests if the generated toml config is loaded correctly as the same Settings object: property -based check #295

Open
mknorps opened this issue Apr 6, 2023 · 0 comments
Labels
good first issue Good for newcomers P3 minor: not priorized type: refactoring

Comments

@mknorps
Copy link
Collaborator

mknorps commented Apr 6, 2023

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.

@jherland jherland added the P3 minor: not priorized label Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers P3 minor: not priorized type: refactoring
Projects
None yet
Development

No branches or pull requests

2 participants