-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtest_linux_git.py
More file actions
executable file
·53 lines (35 loc) · 1.4 KB
/
test_linux_git.py
File metadata and controls
executable file
·53 lines (35 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os.path
import shutil
import subprocess
import tempfile
import unittest
from . import support
class TestLinuxGit(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix="ks_linux_git")
self.lg_path = support.testdir() / '../../linux_git.sh'
def tearDown(self):
shutil.rmtree(self.tmpdir)
def run_one(self, *, bare, var, output):
args = ["git", "init", "--quiet"]
if bare:
args.append("--bare")
args.append(self.tmpdir)
subprocess.check_call(args, env={}, cwd=self.tmpdir)
retval = subprocess.check_output([self.lg_path],
env={"LINUX_GIT" : var}, cwd=self.tmpdir)
self.assertEqual(output, retval.decode())
def test_bare(self):
self.run_one(bare=True, var=self.tmpdir, output=self.tmpdir + "\n")
def test_nonbare(self):
self.run_one(bare=False, var=self.tmpdir,
output=os.path.join(self.tmpdir, ".git") + "\n")
def test_nonbare_git(self):
self.run_one(bare=False, var=os.path.join(self.tmpdir, ".git"),
output=os.path.join(self.tmpdir, ".git") + "\n")
if __name__ == '__main__':
# Run a single testcase
suite = unittest.TestLoader().loadTestsFromTestCase(TestLinuxGit)
unittest.TextTestRunner(verbosity=2).run(suite)