def METHOD_NAME(self, monkeypatch):
    '''pwd is not readable, use instance's tmpdir property'''
    def mock_getcwd():
        return '/tmp'
    def mock_access(path, perm):
        if path == '/tmp' and perm == 4:
            return False
        return True
    def mock_expandvars(var):
        if var == '$HOME':
            return '/home/foobar'
        return var
    def mock_gettempdir():
        return '/tmp/testdir'
    def mock_chdir(path):
        if path == '/tmp':
            raise Exception()
        return
    monkeypatch.setattr(os, 'getcwd', mock_getcwd)
    monkeypatch.setattr(os, 'chdir', mock_chdir)
    monkeypatch.setattr(os, 'access', mock_access)
    monkeypatch.setattr(os.path, 'expandvars', mock_expandvars)
    monkeypatch.setattr(basic, '_ANSIBLE_ARGS', to_bytes(json.dumps({'ANSIBLE_MODULE_ARGS': {}})))
    with patch('time.time', return_value=42):
        am = basic.AnsibleModule(argument_spec={})
    am._tmpdir = '/tmp2'
    result = am._set_cwd()
    assert result == am._tmpdir