def test_write_my_settings(monkeypatch, tmp_path, my_settings):
    """Make sure that settings are written correctly."""
    monkeypatch.setattr(my_code, "MY_SETTINGS_PATH",
                        tmp_path / ".my_fake_settings")
    my_code.write_my_settings(my_settings)
    retrieved_settings = eval(my_code.MY_SETTINGS_PATH.read_text())
    assert retrieved_settings == my_settings
Exemple #2
0
def test_write_my_settings_no_fixtures():
    """Make sure that settings are written correctly."""
    old_path = my_code.MY_SETTINGS_PATH
    try:
        with tempfile.TemporaryDirectory() as tmpdir:
            my_code.MY_SETTINGS_PATH = Path(tmpdir) / '.my_fake_settings'
            fake_settings = {'name': 'Oliver'}
            my_code.write_my_settings(fake_settings)
            retrieved_settings = my_code.MY_SETTINGS_PATH.read_text()
            assert eval(retrieved_settings) == fake_settings
    finally:
        my_code.MY_SETTINGS_PATH = old_path
def test_write_my_settings(my_settings):
    """Make sure that settings are written correctly."""
    my_code.write_my_settings(my_settings)
    retrieved_settings = eval(my_code.MY_SETTINGS_PATH.read_text())
    assert retrieved_settings == my_settings