示例#1
0
 def __enter__(self):
     if windows():
         if not exists(self._dir):
             makedirs(self._dir)
         return self._dir
     else:
         self._context = self._context()
         return self._context.__enter__()
示例#2
0
def test_CONFIGDIR_middle():
    if not windows():  # gets confused over messed up path
        with WindowsTemp(TemporaryDirectory) as dir:
            dir = canonify(dir)
            config = join(dir, '.rover')
            with open(config, 'w') as output:
                output.write('temp-dir=xx${CONFIGDIR}/foo\n')
                output.write('data-dir=xx$${CONFIGDIR}/foo\n')
            argparse = Arguments()
            args, config_path = argparse.parse_args(['-f', config])
            config = BaseConfig(None, None, args, None, dirname(config_path))
            assert config.dir(TEMPDIR)
            assert config.dir(TEMPDIR) == canonify(join(dir, 'xx' + dir + '/foo')), config.dir(TEMPDIR)
            assert config.dir(DATADIR)
            assert config.dir(DATADIR) == canonify(dir + '/xx' + canonify(dir) + '/foo'), config.dir(DATADIR)
示例#3
0
 def __exit__(self, exc_type, exc_val, exc_tb):
     if windows():
         if self._cleanup:
             rmtree(self._dir, ignore_errors=True)
     else:
         return self._context.__exit__(exc_type, exc_val, exc_tb)