diff options
author | Konrad Weihmann <kweihmann@outlook.com> | 2020-07-12 15:05:33 +0200 |
---|---|---|
committer | Konrad Weihmann <kweihmann@outlook.com> | 2020-07-12 15:41:51 +0200 |
commit | e0b10d965d6377c409ceb40eb47379d79c3fef9f (patch) | |
tree | 0f5cd65c1db04255862b8c19f4bf73cab435c4f0 | |
parent | 961539ced52c82519767a4c9e5852dbeccfc974e (diff) | |
download | gitpython-e0b10d965d6377c409ceb40eb47379d79c3fef9f.tar.gz |
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 <kweihmann@outlook.com>
-rw-r--r-- | test-requirements.txt | 1 | ||||
-rw-r--r-- | test/test_installation.py | 29 |
2 files changed, 30 insertions, 0 deletions
diff --git a/test-requirements.txt b/test-requirements.txt index 574c21f0..a85eb683 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,4 @@ ddt>=1.1.1 coverage flake8 tox +virtualenv diff --git a/test/test_installation.py b/test/test_installation.py new file mode 100644 index 00000000..db14bc84 --- /dev/null +++ b/test/test_installation.py @@ -0,0 +1,29 @@ +# This module is part of GitPython and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php + +import os +import subprocess +from test.lib import TestBase +from test.lib.helper import with_rw_directory + + +class TestInstallation(TestBase): + def setUp_venv(self, rw_dir): + self.venv = rw_dir + subprocess.run(['virtualenv', self.venv], stdout=subprocess.PIPE) + self.python = os.path.join(self.venv, 'bin/python3') + self.pip = os.path.join(self.venv, 'bin/pip3') + self.sources = os.path.join(self.venv, "src") + self.cwd = os.path.dirname(os.path.dirname(__file__)) + os.symlink(self.cwd, self.sources, target_is_directory=True) + + @with_rw_directory + def test_installation(self, rw_dir): + self.setUp_venv(rw_dir) + result = subprocess.run([self.pip, 'install', '-r', 'requirements.txt'], + stdout=subprocess.PIPE, cwd=self.sources) + self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't install requirements") + result = subprocess.run([self.python, 'setup.py', 'install'], stdout=subprocess.PIPE, cwd=self.sources) + self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Can't build - setup.py failed") + result = subprocess.run([self.python, '-c', 'import git'], stdout=subprocess.PIPE, cwd=self.sources) + self.assertEqual(0, result.returncode, msg=result.stderr or result.stdout or "Selftest failed") |