def test_makedirs_py3(mock_makedirs): # just check stuff get's forwarded with patch('osfclient.utils.six.PY3', True): makedirs('/this/path/exists', exist_ok=True) expected = [call('/this/path/exists', 511, True)] assert expected == mock_makedirs.mock_calls
def test_makedirs_exist_ok_py2(mock_makedirs, mock_path): # pretend to be in python 2 land # path already exists, expect NOT to call makedirs as we set exist_ok mock_path.exists.return_value = True with patch('osfclient.utils.six.PY3', False): makedirs('/this/path/exists', exist_ok=True) assert not mock_makedirs.called
def test_makedirs_doesnt_exist_py2(mock_makedirs, mock_path): # pretend to be in python 2 land mock_path.exists.return_value = False with patch('osfclient.utils.six.PY3', False): makedirs('/this/path/doesnt/exists') expected = [call('/this/path/doesnt/exists', 511)] assert expected == mock_makedirs.mock_calls
def test_makedirs_py2(mock_makedirs, mock_path): # pretend to be in python 2 land # path already exists, expect to call makedirs and that will raise mock_path.exists.return_value = True with patch('osfclient.utils.six.PY3', False): makedirs('/this/path/exists') expected = [call('/this/path/exists', 511)] assert expected == mock_makedirs.mock_calls