Exemplo n.º 1
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)
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 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)
Exemplo n.º 5
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 9
0
def _tmp_root():
    root = os.path.join(tempfile.gettempdir(), 'peru', 'test')
    makedirs(root)
    return root
Exemplo n.º 10
0
def _tmp_root():
    root = os.path.join(tempfile.gettempdir(), 'peru', 'test')
    makedirs(root)
    return root
Exemplo n.º 11
0
def _tmp_root():
    root = '/tmp/peru/test'
    makedirs(root)
    return root