Exemplo n.º 1
0
    def test_tar_this_file_succeeds(self):
        # `tar` complains about absolute paths, so use a relative path here.
        source = os.path.relpath(__file__)
        _, destination = tempfile.mkstemp()
        tar(source=source, destination=destination)

        if platform.system() == "Darwin":
            expect = "+ tar -c -z -f {dest} {source}\n"
        else:
            expect = "+ tar -c -z -f {dest} --owner=0 --group=0 {source}\n"

        self.assertEqual(self.stdout.getvalue(), "")
        self.assertEqual(self.stderr.getvalue(),
                         expect.format(dest=destination, source=source))
Exemplo n.º 2
0
    def test_tar_this_file_succeeds(self):
        # `tar` complains about absolute paths, so use a relative path here.
        if platform.system() != 'Windows':
            source = os.path.relpath(__file__)
        else:
            # Windows can use absolute paths, specially because the relative
            # path might not exist because the file and the current directory
            # might be in different drives.
            source = __file__
        _, destination = tempfile.mkstemp()
        tar(source=source, destination=destination)

        if platform.system() == "Darwin" or platform.system() == 'Windows':
            expect = "+ tar -c -z -f {dest} {source}\n"
        else:
            expect = "+ tar -c -z -f {dest} --owner=0 --group=0 {source}\n"

        self.assertEqual(self.stdout.getvalue(), "")
        self.assertEqual(
            self.stderr.getvalue(),
            expect.format(dest=self._platform_quote(destination),
                          source=self._platform_quote(source)))
Exemplo n.º 3
0
 def test_tar_nonexistent_file_raises(self):
     with self.assertRaises(SystemExit):
         tar(source='/path/to/something/that/surely/doesnt/exist',
             destination='/another/path/that/shouldnt/exist')
Exemplo n.º 4
0
 def test_tar_nonexistent_file_raises(self):
     with self.assertRaises(subprocess.CalledProcessError):
         tar(source='/path/to/something/that/surely/doesnt/exist',
             destination='/another/path/that/shouldnt/exist')
Exemplo n.º 5
0
 def test_tar_this_file_succeeds(self):
     # `tar` complains about absolute paths, so use a relative path here.
     source = os.path.relpath(__file__)
     _, destination = tempfile.mkstemp()
     tar(source=source, destination=destination)
Exemplo n.º 6
0
 def test_tar_nonexistent_file_raises(self):
     with self.assertRaises(subprocess.CalledProcessError):
         tar(source='/path/to/something/that/surely/doesnt/exist',
             destination='/another/path/that/shouldnt/exist')
Exemplo n.º 7
0
 def test_tar_this_file_succeeds(self):
     # `tar` complains about absolute paths, so use a relative path here.
     source = os.path.relpath(__file__)
     _, destination = tempfile.mkstemp()
     tar(source=source, destination=destination)