示例#1
0
文件: test_paths.py 项目: emgee/peru
    def setUp(self):
        self.test_root = shared.create_dir()

        self.project_dir = os.path.join(self.test_root, 'project')
        self.state_dir = os.path.join(self.project_dir, '.peru')
        self.cache_dir = os.path.join(self.state_dir, 'cache')

        self.yaml = textwrap.dedent('''\
            imports:
                foo: ./
            cp module foo:
                # relative paths should always be interpreted from the dir
                # containing peru.yaml, even if that's not the sync dir.
                path: ../foo
            ''')
        shared.write_files(self.project_dir, {'peru.yaml': self.yaml})
        self.peru_file = os.path.join(self.project_dir, 'peru.yaml')

        self.foo_dir = os.path.join(self.test_root, 'foo')
        shared.write_files(self.foo_dir, {'bar': 'baz'})

        # We'll run tests from this inner subdirectory, so that we're more
        # likely to catch places where we're using the cwd incorrectly.
        self.cwd = os.path.join(self.project_dir, 'cwd', 'in', 'here')
        makedirs(self.cwd)
示例#2
0
    def setUp(self):
        self.test_root = shared.create_dir()

        self.project_dir = os.path.join(self.test_root, 'project')
        self.state_dir = os.path.join(self.project_dir, '.peru')
        self.cache_dir = os.path.join(self.state_dir, 'cache')

        self.yaml = textwrap.dedent('''\
            imports:
                foo: ./
            cp module foo:
                # relative paths should always be interpreted from the dir
                # containing peru.yaml, even if that's not the sync dir.
                path: ../foo
            ''')
        shared.write_files(self.project_dir, {'peru.yaml': self.yaml})
        self.peru_file = os.path.join(self.project_dir, 'peru.yaml')

        self.foo_dir = os.path.join(self.test_root, 'foo')
        shared.write_files(self.foo_dir, {'bar': 'baz'})

        # We'll run tests from this inner subdirectory, so that we're more
        # likely to catch places where we're using the cwd incorrectly.
        self.cwd = os.path.join(self.project_dir, 'cwd', 'in', 'here')
        makedirs(self.cwd)
示例#3
0
文件: shared.py 项目: Arvindhm/peru
def write_files(dir, path_contents_map):
    dir = Path(dir)
    for path, contents in path_contents_map.items():
        path = Path(path)
        full_path = dir / path
        makedirs(str(full_path.parent))
        with full_path.open('w') as f:
            f.write(contents)
示例#4
0
def write_files(dir, path_contents_map):
    dir = Path(dir)
    for path, contents in path_contents_map.items():
        path = Path(path)
        full_path = dir / path
        makedirs(str(full_path.parent))
        with full_path.open('w') as f:
            f.write(contents)
示例#5
0
文件: test_compat.py 项目: emgee/peru
 def test_makedirs(self):
     tmp_dir = shared.tmp_dir()
     foo_dir = os.path.join(tmp_dir, "foo")
     compat.makedirs(foo_dir)
     os.chmod(foo_dir, 0o700)
     # Creating the dir again should be a no-op even though the permissions
     # have changed.
     compat.makedirs(foo_dir)
示例#6
0
 def test_makedirs(self):
     tmp_dir = shared.tmp_dir()
     foo_dir = os.path.join(tmp_dir, "foo")
     compat.makedirs(foo_dir)
     os.chmod(foo_dir, 0o700)
     # Creating the dir again should be a no-op even though the permissions
     # have changed.
     compat.makedirs(foo_dir)
示例#7
0
def write_files(dir, path_contents_map):
    dir = Path(dir)
    for path, contents in path_contents_map.items():
        path = Path(path)
        full_path = dir / path
        makedirs(str(full_path.parent))
        with full_path.open('w') as f:
            # Handle both string and bytes values.
            if type(contents) is str:
                f.write(contents)
            else:
                f.buffer.write(contents)
示例#8
0
def write_files(dir, path_contents_map):
    dir = Path(dir)
    for path, contents in path_contents_map.items():
        path = Path(path)
        full_path = dir / path
        makedirs(str(full_path.parent))
        with full_path.open('w') as f:
            # Handle both string and bytes values.
            if type(contents) is str:
                f.write(contents)
            else:
                f.buffer.write(contents)
示例#9
0
def _tmp_root():
    root = os.path.join(tempfile.gettempdir(), 'peru', 'test')
    makedirs(root)
    return root
示例#10
0
文件: shared.py 项目: Arvindhm/peru
def _tmp_root():
    root = os.path.join(tempfile.gettempdir(), 'peru', 'test')
    makedirs(root)
    return root
示例#11
0
文件: shared.py 项目: mgartner/peru
def _tmp_root():
    root = '/tmp/peru/test'
    makedirs(root)
    return root