Skip to content

Commit e0b10d9

Browse files
test: add installation test
which installs the current codebase in a venv and runs 'import git' to test if codebase can be installed properly. This adds virtualenv to the test requirements Signed-off-by: Konrad Weihmann <[email protected]>
1 parent 961539c commit e0b10d9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ ddt>=1.1.1
22
coverage
33
flake8
44
tox
5+
virtualenv

Diff for: test/test_installation.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This module is part of GitPython and is released under
2+
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
3+
4+
import os
5+
import subprocess
6+
from test.lib import TestBase
7+
from test.lib.helper import with_rw_directory
8+
9+
10+
class TestInstallation(TestBase):
11+
def setUp_venv(self, rw_dir):
12+
self.venv = rw_dir
13+
subprocess.run(['virtualenv', self.venv], stdout=subprocess.PIPE)
14+
self.python = os.path.join(self.venv, 'bin/python3')
15+
self.pip = os.path.join(self.venv, 'bin/pip3')
16+
self.sources = os.path.join(self.venv, "src")
17+
self.cwd = os.path.dirname(os.path.dirname(__file__))
18+
os.symlink(self.cwd, self.sources, target_is_directory=True)
19+
20+
@with_rw_directory
21+
def test_installation(self, rw_dir):
22+
self.setUp_venv(rw_dir)
23+
result = subprocess.run([self.pip, 'install', '-r', 'requirements.txt'],
24+
stdout=subprocess.PIPE, cwd=self.sources)
25+
self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't install requirements")
26+
result = subprocess.run([self.python, 'setup.py', 'install'], stdout=subprocess.PIPE, cwd=self.sources)
27+
self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't build - setup.py failed")
28+
result = subprocess.run([self.python, '-c', 'import git'], stdout=subprocess.PIPE, cwd=self.sources)
29+
self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Selftest failed")

0 commit comments

Comments
 (0)