def test_write_config(self, monkeypatch): fcontent = json.loads('{"123":"abc"}') mo = mock.mock_open() with mock.patch.object(builtins, 'open', mo): focli.write_config(fcontent) mo.assert_called_once_with( os.path.expanduser(focli.CONFIG_PATH), 'w')
def test_write_config_exception(self, monkeypatch): with mock.patch.object(builtins, 'open', mock.mock_open()): with pytest.raises(TypeError): focli.write_config(set())
def test_write_config(self, monkeypatch): fcontent = json.loads('{"123":"abc"}') mo = mock.mock_open() with mock.patch.object(builtins, 'open', mo): focli.write_config(fcontent) mo.assert_called_once_with(os.path.expanduser(focli.CONFIG_PATH), 'w')
def test_write_config_exception(self, monkeypatch): with mock.patch.object(builtins, 'open', mock.mock_open()): with pytest.raises(TypeError): focli.write_config(set())