Skip to content

Commit

Permalink
Merge pull request #1031 from priv-kweihmann/move-test-2nd
Browse files Browse the repository at this point in the history
[RFC/WIP] move tests and avoid packaging them
  • Loading branch information
Byron committed Jul 13, 2020
2 parents 9cb7ae8 + e0b10d9 commit 3edd16c
Show file tree
Hide file tree
Showing 106 changed files with 97 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version = 1

test_patterns = [
'git/test/**/test_*.py'
'test/**/test_*.py'
]

exclude_patterns = [
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
git/test/fixtures/* eol=lf
test/fixtures/* eol=lf
init-tests-after-clone.sh
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
git config --global user.name "Travis Runner"
# If we rewrite the user's config by accident, we will mess it up
# and cause subsequent tests to fail
cat git/test/fixtures/.gitconfig >> ~/.gitconfig
cat test/fixtures/.gitconfig >> ~/.gitconfig
- name: Lint with flake8
run: |
set -x
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ script:
# Make sure we limit open handles to see if we are leaking them
- ulimit -n 128
- ulimit -n
- coverage run --omit="git/test/*" -m unittest --buffer
- coverage run --omit="test/*" -m unittest --buffer
- coverage report
- if [ "$TRAVIS_PYTHON_VERSION" == '3.5' ]; then cd doc && make html; fi
- if [ "$TRAVIS_PYTHON_VERSION" == '3.6' ]; then flake8 --ignore=W293,E265,E266,W503,W504,E731; fi
Expand Down
5 changes: 1 addition & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ include AUTHORS
include CONTRIBUTING.md
include README.md
include requirements.txt
include test-requirements.txt

recursive-include doc *

graft git/test/fixtures
graft git/test/performance
recursive-exclude test *

global-exclude __pycache__ *.pyc
25 changes: 22 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from distutils.command.build_py import build_py as _build_py
from setuptools.command.sdist import sdist as _sdist
import fnmatch
import os
import sys
from os import path
Expand Down Expand Up @@ -66,6 +67,24 @@ def _stamp_version(filename):
print("WARNING: Couldn't find version line in file %s" % filename, file=sys.stderr)


def build_py_modules(basedir, excludes=[]):
# create list of py_modules from tree
res = set()
_prefix = os.path.basename(basedir)
for root, _, files in os.walk(basedir):
for f in files:
_f, _ext = os.path.splitext(f)
if _ext not in [".py"]:
continue
_f = os.path.join(root, _f)
_f = os.path.relpath(_f, basedir)
_f = "{}.{}".format(_prefix, _f.replace(os.sep, "."))
if any(fnmatch.fnmatch(_f, x) for x in excludes):
continue
res.add(_f)
return list(res)


setup(
name="GitPython",
cmdclass={'build_py': build_py, 'sdist': sdist},
Expand All @@ -74,9 +93,9 @@ def _stamp_version(filename):
author="Sebastian Thiel, Michael Trier",
author_email="byronimo@gmail.com, mtrier@gmail.com",
url="https://github.com/gitpython-developers/GitPython",
packages=find_packages('.'),
py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
package_data={'git.test': ['fixtures/*']},
packages=find_packages(exclude=("test.*")),
include_package_data=True,
py_modules=build_py_modules("./git", excludes=["git.ext.*"]),
package_dir={'git': 'git'},
python_requires='>=3.4',
install_requires=requirements,
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ddt>=1.1.1
coverage
flake8
tox
virtualenv
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ index f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3..a88a777df3909a61be97f1a7b1194dad
@@ -1 +1 @@
-Subproject commit f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3
+Subproject commit a88a777df3909a61be97f1a7b1194dad6de25702-dirty
diff --git a/git/test/fixtures/diff_patch_binary b/git/test/fixtures/diff_patch_binary
diff --git a/test/fixtures/diff_patch_binary b/test/fixtures/diff_patch_binary
new file mode 100644
index 0000000000000000000000000000000000000000..c92ccd6ebc92a871d38ad7cb8a48bcdb1a5dbc33
--- /dev/null
+++ b/git/test/fixtures/diff_patch_binary
+++ b/test/fixtures/diff_patch_binary
@@ -0,0 +1,3 @@
+diff --git a/rps b/rps
+index f4567df37451b230b1381b1bc9c2bcad76e08a3c..736bd596a36924d30b480942e9475ce0d734fa0d 100755
+Binary files a/rps and b/rps differ
diff --git a/git/test/fixtures/diff_raw_binary b/git/test/fixtures/diff_raw_binary
diff --git a/test/fixtures/diff_raw_binary b/test/fixtures/diff_raw_binary
new file mode 100644
index 0000000000000000000000000000000000000000..d4673fa41ee8413384167fc7b9f25e4daf18a53a
--- /dev/null
+++ b/git/test/fixtures/diff_raw_binary
+++ b/test/fixtures/diff_raw_binary
@@ -0,0 +1 @@
+:100755 100755 f4567df37451b230b1381b1bc9c2bcad76e08a3c 736bd596a36924d30b480942e9475ce0d734fa0d M rps
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
diff --git a/test/test_diff.py b/test/test_diff.py
index ce0f64f2261bd8de063233108caac1f26742c1fd..4de26f8884fd048ac7f10007f2bf7c7fa3fa60f4 100644
--- a/git/test/test_diff.py
+++ b/git/test/test_diff.py
--- a/test/test_diff.py
+++ b/test/test_diff.py
@@ -65,6 +65,21 @@ class TestDiff(TestBase):
assert diff.rename_to == 'that'
assert len(list(diffs.iter_change_type('R'))) == 1
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion git/test/lib/helper.py → test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

ospd = osp.dirname

GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", ospd(ospd(ospd(ospd(__file__)))))
GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", ospd(ospd(ospd(__file__))))
GIT_DAEMON_PORT = os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT", "19418")

__all__ = (
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion git/test/performance/lib.py → test/performance/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
GitCmdObjectDB,
GitDB
)
from git.test.lib import (
from test.lib import (
TestBase
)
from git.util import rmtree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from .lib import TestBigRepoRW
from git import Commit
from gitdb import IStream
from git.test.test_commit import TestCommitSerialization
from test.test_commit import TestCommitSerialization


class TestPerformance(TestBigRepoRW, TestCommitSerialization):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
from time import time

from git.test.lib import (
from test.lib import (
with_rw_repo
)
from git.util import bin_to_hex
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_actor.py → test/test_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

from git.test.lib import TestBase
from test.lib import TestBase
from git import Actor


Expand Down
2 changes: 1 addition & 1 deletion git/test/test_base.py → test/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from git.compat import is_win
from git.objects.util import get_object_type_by_name
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo,
with_rw_and_rw_remote_repo
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_blob.py → test/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

from git.test.lib import TestBase
from test.lib import TestBase
from git import Blob


Expand Down
4 changes: 2 additions & 2 deletions git/test/test_commit.py → test/test_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
from git import Repo
from git.objects.util import tzoffset, utc
from git.repo.fun import touch
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo,
fixture_path,
StringProcessAdapter
)
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory
from gitdb import IStream

import os.path as osp
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_config.py → test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
GitConfigParser
)
from git.config import _OMD, cp
from git.test.lib import (
from test.lib import (
TestCase,
fixture_path,
SkipTest,
)
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory

import os.path as osp
from git.util import rmfile
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_db.py → test/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
from git.db import GitCmdObjectDB
from git.exc import BadObject
from git.test.lib import TestBase
from test.lib import TestBase
from git.util import bin_to_hex

import os.path as osp
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_diff.py → test/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
Submodule,
)
from git.cmd import Git
from git.test.lib import (
from test.lib import (
TestBase,
StringProcessAdapter,
fixture,
)
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory

import os.path as osp

Expand Down
4 changes: 2 additions & 2 deletions git/test/test_docs.py → test/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import os

from git.test.lib import TestBase
from git.test.lib.helper import with_rw_directory
from test.lib import TestBase
from test.lib.helper import with_rw_directory

import os.path

Expand Down
2 changes: 1 addition & 1 deletion git/test/test_exc.py → test/test_exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
HookExecutionError,
RepositoryDirtyError,
)
from git.test.lib import TestBase
from test.lib import TestBase

import itertools as itt

Expand Down
2 changes: 1 addition & 1 deletion git/test/test_fun.py → test/test_fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from git.repo.fun import (
find_worktree_git_dir
)
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo,
with_rw_directory
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_git.py → test/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
cmd
)
from git.compat import is_darwin
from git.test.lib import (
from test.lib import (
TestBase,
fixture_path
)
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory
from git.util import finalize_process

import os.path as osp
Expand Down
4 changes: 2 additions & 2 deletions git/test/test_index.py → test/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
IndexEntry
)
from git.objects import Blob
from git.test.lib import (
from test.lib import (
TestBase,
fixture_path,
fixture,
with_rw_repo
)
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory
from git.util import Actor, rmtree
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, hex_to_bin
from gitdb.base import IStream
Expand Down
29 changes: 29 additions & 0 deletions test/test_installation.py
Original file line number Diff line number Diff line change
@@ -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")
2 changes: 1 addition & 1 deletion git/test/test_reflog.py → test/test_reflog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RefLogEntry,
RefLog
)
from git.test.lib import (
from test.lib import (
TestBase,
fixture_path
)
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_refs.py → test/test_refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
RefLog
)
from git.objects.tag import TagObject
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo
)
Expand Down
2 changes: 1 addition & 1 deletion git/test/test_remote.py → test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
GitCommandError
)
from git.cmd import Git
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo,
with_rw_and_rw_remote_repo,
Expand Down
6 changes: 3 additions & 3 deletions git/test/test_repo.py → test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
BadObject,
)
from git.repo.fun import touch
from git.test.lib import (
from test.lib import (
TestBase,
with_rw_repo,
fixture
)
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
from git.test.lib import with_rw_directory
from test.lib import with_rw_directory
from git.util import join_path_native, rmtree, rmfile, bin_to_hex

import os.path as osp
Expand Down Expand Up @@ -865,7 +865,7 @@ def last_commit(repo, rev, path):
for _ in range(64):
for repo_type in (GitCmdObjectDB, GitDB):
repo = Repo(self.rorepo.working_tree_dir, odbt=repo_type)
last_commit(repo, 'master', 'git/test/test_base.py')
last_commit(repo, 'master', 'test/test_base.py')
# end for each repository type
# end for each iteration

Expand Down
2 changes: 1 addition & 1 deletion git/test/test_stats.py → test/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php

from git.test.lib import (
from test.lib import (
TestBase,
fixture
)
Expand Down

0 comments on commit 3edd16c

Please sign in to comment.