Esempio n. 1
0
def test_single_save_with_nested_context_manager(mock_save_to_disk: MagicMock,
                                                 option: Options):
    # Setup
    option._dark_mode = False

    # Run
    with option:
        option.dark_mode = True
        with option:
            pass

    # Assert
    mock_save_to_disk.assert_called_once_with(option)
Esempio n. 2
0
def test_save_with_context_manager(mock_save_to_disk: MagicMock,
                                   option: Options):
    # Setup
    settings_changed = MagicMock()
    option._dark_mode = False
    option.on_options_changed = settings_changed

    # Run
    with option:
        option.dark_mode = True

    # Assert
    mock_save_to_disk.assert_called_once_with(option)
    settings_changed.assert_called_once_with()