Code Duplication    Length = 18-19 lines in 2 locations

tests/replay/test_dump.py 1 location

@@ 86-104 (lines=19) @@
83
    mock_ensure_failure.assert_called_once_with(replay_test_dir)
84
85
86
def test_run_json_dump(mocker, mock_ensure_success, mock_user_config,
87
                       template_name, context, replay_test_dir, replay_file):
88
    """Test that replay.dump runs json.dump under the hood and that the context
89
    is correctly written to the expected file in the replay_dir.
90
    """
91
    spy_get_replay_file = mocker.spy(replay, 'get_file_name')
92
93
    mock_json_dump = mocker.patch('json.dump', side_effect=json.dump)
94
95
    replay.dump(replay_test_dir, template_name, context)
96
97
    assert not mock_user_config.called
98
    mock_ensure_success.assert_called_once_with(replay_test_dir)
99
    spy_get_replay_file.assert_called_once_with(replay_test_dir, template_name)
100
101
    assert mock_json_dump.call_count == 1
102
    (dumped_context, outfile_handler), kwargs = mock_json_dump.call_args
103
    assert outfile_handler.name == replay_file
104
    assert dumped_context == context
105

tests/replay/test_load.py 1 location

@@ 48-65 (lines=18) @@
45
        replay.load(replay_test_dir, 'no_replay')
46
47
48
def test_run_json_load(mocker, mock_user_config, template_name,
49
                       context, replay_test_dir, replay_file):
50
    """Test that replay.load runs json.load under the hood and that the context
51
    is correctly loaded from the file in replay_dir.
52
    """
53
    spy_get_replay_file = mocker.spy(replay, 'get_file_name')
54
55
    mock_json_load = mocker.patch('json.load', side_effect=json.load)
56
57
    loaded_context = replay.load(replay_test_dir, template_name)
58
59
    assert not mock_user_config.called
60
    spy_get_replay_file.assert_called_once_with(replay_test_dir, template_name)
61
62
    assert mock_json_load.call_count == 1
63
    (infile_handler,), kwargs = mock_json_load.call_args
64
    assert infile_handler.name == replay_file
65
    assert loaded_context == context
66