Exemplo n.º 1
0
    def test_chdir(self):
        def check_special_envvar():
            if sys.platform != 'win32':
                return
            pwd = os.getcwd()
            import ctypes
            buf = ctypes.create_string_buffer(1000)
            len = ctypes.windll.kernel32.GetEnvironmentVariableA(
                '=%c:' % pwd[0], buf, 1000)
            if (len == 0) and "WINGDB_PYTHON" in os.environ:
                # the ctypes call seems not to work in the Wing debugger
                return
            assert str(buf.value).lower() == pwd.lower()
            # ctypes returns the drive letter in uppercase,
            # os.getcwd does not,
            # but there may be uppercase in os.getcwd path

        pwd = os.getcwd()
        try:
            check_special_envvar()
            rposix.chdir('..')
            assert os.getcwd() == os.path.dirname(pwd)
            check_special_envvar()
        finally:
            os.chdir(pwd)
Exemplo n.º 2
0
def get_valid_cwd():
    """ We check if the current working directory is valid or not. Typically
    happens when you checkout a different branch on git that doesn't have
    this directory.
    We return the original cwd because the shell still considers that to be
    the working directory, so returning our guess will confuse people
  """
    cwd = os.environ[_as_bytes('PWD')]
    parts = cwd.split(os.sep)
    up = cwd
    while parts and not os.path.exists(up):
        parts.pop()
        up = os.sep.join(parts)
    chdir(up)
    return cwd
Exemplo n.º 3
0
def get_valid_cwd():
  """ We check if the current working directory is valid or not. Typically
    happens when you checkout a different branch on git that doesn't have
    this directory.
    We return the original cwd because the shell still considers that to be
    the working directory, so returning our guess will confuse people
  """
  cwd = os.environ[_as_bytes('PWD')]
  parts = cwd.split(os.sep)
  up = cwd
  while parts and not os.path.exists(up):
    parts.pop()
    up = os.sep.join(parts)
  chdir(up)
  return cwd
Exemplo n.º 4
0
    def test_chdir(self):
        def check_special_envvar():
            if sys.platform != 'win32':
                return
            pwd = os.getcwd()
            import ctypes
            buf = ctypes.create_string_buffer(1000)
            len = ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 1000)
            if (len == 0) and "WINGDB_PYTHON" in os.environ:
                # the ctypes call seems not to work in the Wing debugger
                return
            assert str(buf.value).lower() == pwd.lower()
            # ctypes returns the drive letter in uppercase,
            # os.getcwd does not,
            # but there may be uppercase in os.getcwd path

        pwd = os.getcwd()
        try:
            check_special_envvar()
            rposix.chdir('..')
            assert os.getcwd() == os.path.dirname(pwd)
            check_special_envvar()
        finally:
            os.chdir(pwd)
Exemplo n.º 5
0
 def f():
     rposix.mkdir(self.path, 0777)
     rposix.chdir(self.path)
Exemplo n.º 6
0
 def f():
     rposix.mkdir(self.path, 0777)
     rposix.chdir(self.path)