Skip to content

Commit 3edd16c

Browse files
authored
Merge pull request #1031 from priv-kweihmann/move-test-2nd
[RFC/WIP] move tests and avoid packaging them
2 parents 9cb7ae8 + e0b10d9 commit 3edd16c

File tree

106 files changed

+97
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+97
-51
lines changed

Diff for: .deepsource.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version = 1
22

33
test_patterns = [
4-
'git/test/**/test_*.py'
4+
'test/**/test_*.py'
55
]
66

77
exclude_patterns = [

Diff for: .gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
git/test/fixtures/* eol=lf
1+
test/fixtures/* eol=lf
22
init-tests-after-clone.sh

Diff for: .github/workflows/pythonpackage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
git config --global user.name "Travis Runner"
4141
# If we rewrite the user's config by accident, we will mess it up
4242
# and cause subsequent tests to fail
43-
cat git/test/fixtures/.gitconfig >> ~/.gitconfig
43+
cat test/fixtures/.gitconfig >> ~/.gitconfig
4444
- name: Lint with flake8
4545
run: |
4646
set -x

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ script:
3636
# Make sure we limit open handles to see if we are leaking them
3737
- ulimit -n 128
3838
- ulimit -n
39-
- coverage run --omit="git/test/*" -m unittest --buffer
39+
- coverage run --omit="test/*" -m unittest --buffer
4040
- coverage report
4141
- if [ "$TRAVIS_PYTHON_VERSION" == '3.5' ]; then cd doc && make html; fi
4242
- if [ "$TRAVIS_PYTHON_VERSION" == '3.6' ]; then flake8 --ignore=W293,E265,E266,W503,W504,E731; fi

Diff for: MANIFEST.in

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ include AUTHORS
55
include CONTRIBUTING.md
66
include README.md
77
include requirements.txt
8-
include test-requirements.txt
98

109
recursive-include doc *
11-
12-
graft git/test/fixtures
13-
graft git/test/performance
10+
recursive-exclude test *
1411

1512
global-exclude __pycache__ *.pyc

Diff for: setup.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

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

6869

70+
def build_py_modules(basedir, excludes=[]):
71+
# create list of py_modules from tree
72+
res = set()
73+
_prefix = os.path.basename(basedir)
74+
for root, _, files in os.walk(basedir):
75+
for f in files:
76+
_f, _ext = os.path.splitext(f)
77+
if _ext not in [".py"]:
78+
continue
79+
_f = os.path.join(root, _f)
80+
_f = os.path.relpath(_f, basedir)
81+
_f = "{}.{}".format(_prefix, _f.replace(os.sep, "."))
82+
if any(fnmatch.fnmatch(_f, x) for x in excludes):
83+
continue
84+
res.add(_f)
85+
return list(res)
86+
87+
6988
setup(
7089
name="GitPython",
7190
cmdclass={'build_py': build_py, 'sdist': sdist},
@@ -74,9 +93,9 @@ def _stamp_version(filename):
7493
author="Sebastian Thiel, Michael Trier",
7594
7695
url="https://github.com/gitpython-developers/GitPython",
77-
packages=find_packages('.'),
78-
py_modules=['git.' + f[:-3] for f in os.listdir('./git') if f.endswith('.py')],
79-
package_data={'git.test': ['fixtures/*']},
96+
packages=find_packages(exclude=("test.*")),
97+
include_package_data=True,
98+
py_modules=build_py_modules("./git", excludes=["git.ext.*"]),
8099
package_dir={'git': 'git'},
81100
python_requires='>=3.4',
82101
install_requires=requirements,

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: git/test/__init__.py renamed to test/__init__.py

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.

Diff for: git/test/fixtures/diff_index_patch renamed to test/fixtures/diff_index_patch

+7-7
Original file line numberDiff line numberDiff line change
@@ -56,26 +56,26 @@ index f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3..a88a777df3909a61be97f1a7b1194dad
5656
@@ -1 +1 @@
5757
-Subproject commit f2233fbf40f3f69309ce5cc714e99fcbdcd33ec3
5858
+Subproject commit a88a777df3909a61be97f1a7b1194dad6de25702-dirty
59-
diff --git a/git/test/fixtures/diff_patch_binary b/git/test/fixtures/diff_patch_binary
59+
diff --git a/test/fixtures/diff_patch_binary b/test/fixtures/diff_patch_binary
6060
new file mode 100644
6161
index 0000000000000000000000000000000000000000..c92ccd6ebc92a871d38ad7cb8a48bcdb1a5dbc33
6262
--- /dev/null
63-
+++ b/git/test/fixtures/diff_patch_binary
63+
+++ b/test/fixtures/diff_patch_binary
6464
@@ -0,0 +1,3 @@
6565
+diff --git a/rps b/rps
6666
+index f4567df37451b230b1381b1bc9c2bcad76e08a3c..736bd596a36924d30b480942e9475ce0d734fa0d 100755
6767
+Binary files a/rps and b/rps differ
68-
diff --git a/git/test/fixtures/diff_raw_binary b/git/test/fixtures/diff_raw_binary
68+
diff --git a/test/fixtures/diff_raw_binary b/test/fixtures/diff_raw_binary
6969
new file mode 100644
7070
index 0000000000000000000000000000000000000000..d4673fa41ee8413384167fc7b9f25e4daf18a53a
7171
--- /dev/null
72-
+++ b/git/test/fixtures/diff_raw_binary
72+
+++ b/test/fixtures/diff_raw_binary
7373
@@ -0,0 +1 @@
7474
+:100755 100755 f4567df37451b230b1381b1bc9c2bcad76e08a3c 736bd596a36924d30b480942e9475ce0d734fa0d M rps
75-
diff --git a/git/test/test_diff.py b/git/test/test_diff.py
75+
diff --git a/test/test_diff.py b/test/test_diff.py
7676
index ce0f64f2261bd8de063233108caac1f26742c1fd..4de26f8884fd048ac7f10007f2bf7c7fa3fa60f4 100644
77-
--- a/git/test/test_diff.py
78-
+++ b/git/test/test_diff.py
77+
--- a/test/test_diff.py
78+
+++ b/test/test_diff.py
7979
@@ -65,6 +65,21 @@ class TestDiff(TestBase):
8080
assert diff.rename_to == 'that'
8181
assert len(list(diffs.iter_change_type('R'))) == 1
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.

Diff for: git/test/lib/helper.py renamed to test/lib/helper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
ospd = osp.dirname
3131

32-
GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", ospd(ospd(ospd(ospd(__file__)))))
32+
GIT_REPO = os.environ.get("GIT_PYTHON_TEST_GIT_REPO_BASE", ospd(ospd(ospd(__file__))))
3333
GIT_DAEMON_PORT = os.environ.get("GIT_PYTHON_TEST_GIT_DAEMON_PORT", "19418")
3434

3535
__all__ = (
File renamed without changes.

Diff for: git/test/performance/lib.py renamed to test/performance/lib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
GitCmdObjectDB,
1111
GitDB
1212
)
13-
from git.test.lib import (
13+
from test.lib import (
1414
TestBase
1515
)
1616
from git.util import rmtree

Diff for: git/test/performance/test_commit.py renamed to test/performance/test_commit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .lib import TestBigRepoRW
1212
from git import Commit
1313
from gitdb import IStream
14-
from git.test.test_commit import TestCommitSerialization
14+
from test.test_commit import TestCommitSerialization
1515

1616

1717
class TestPerformance(TestBigRepoRW, TestCommitSerialization):
File renamed without changes.

Diff for: git/test/performance/test_streams.py renamed to test/performance/test_streams.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77
from time import time
88

9-
from git.test.lib import (
9+
from test.lib import (
1010
with_rw_repo
1111
)
1212
from git.util import bin_to_hex

Diff for: git/test/test_actor.py renamed to test/test_actor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7-
from git.test.lib import TestBase
7+
from test.lib import TestBase
88
from git import Actor
99

1010

Diff for: git/test/test_base.py renamed to test/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818
from git.compat import is_win
1919
from git.objects.util import get_object_type_by_name
20-
from git.test.lib import (
20+
from test.lib import (
2121
TestBase,
2222
with_rw_repo,
2323
with_rw_and_rw_remote_repo

Diff for: git/test/test_blob.py renamed to test/test_blob.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7-
from git.test.lib import TestBase
7+
from test.lib import TestBase
88
from git import Blob
99

1010

Diff for: git/test/test_commit.py renamed to test/test_commit.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
from git import Repo
2121
from git.objects.util import tzoffset, utc
2222
from git.repo.fun import touch
23-
from git.test.lib import (
23+
from test.lib import (
2424
TestBase,
2525
with_rw_repo,
2626
fixture_path,
2727
StringProcessAdapter
2828
)
29-
from git.test.lib import with_rw_directory
29+
from test.lib import with_rw_directory
3030
from gitdb import IStream
3131

3232
import os.path as osp

Diff for: git/test/test_config.py renamed to test/test_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
GitConfigParser
1212
)
1313
from git.config import _OMD, cp
14-
from git.test.lib import (
14+
from test.lib import (
1515
TestCase,
1616
fixture_path,
1717
SkipTest,
1818
)
19-
from git.test.lib import with_rw_directory
19+
from test.lib import with_rw_directory
2020

2121
import os.path as osp
2222
from git.util import rmfile

Diff for: git/test/test_db.py renamed to test/test_db.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66
from git.db import GitCmdObjectDB
77
from git.exc import BadObject
8-
from git.test.lib import TestBase
8+
from test.lib import TestBase
99
from git.util import bin_to_hex
1010

1111
import os.path as osp

Diff for: git/test/test_diff.py renamed to test/test_diff.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
Submodule,
1717
)
1818
from git.cmd import Git
19-
from git.test.lib import (
19+
from test.lib import (
2020
TestBase,
2121
StringProcessAdapter,
2222
fixture,
2323
)
24-
from git.test.lib import with_rw_directory
24+
from test.lib import with_rw_directory
2525

2626
import os.path as osp
2727

Diff for: git/test/test_docs.py renamed to test/test_docs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
77
import os
88

9-
from git.test.lib import TestBase
10-
from git.test.lib.helper import with_rw_directory
9+
from test.lib import TestBase
10+
from test.lib.helper import with_rw_directory
1111

1212
import os.path
1313

Diff for: git/test/test_exc.py renamed to test/test_exc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
HookExecutionError,
2323
RepositoryDirtyError,
2424
)
25-
from git.test.lib import TestBase
25+
from test.lib import TestBase
2626

2727
import itertools as itt
2828

Diff for: git/test/test_fun.py renamed to test/test_fun.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from git.repo.fun import (
1919
find_worktree_git_dir
2020
)
21-
from git.test.lib import (
21+
from test.lib import (
2222
TestBase,
2323
with_rw_repo,
2424
with_rw_directory

Diff for: git/test/test_git.py renamed to test/test_git.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
cmd
2020
)
2121
from git.compat import is_darwin
22-
from git.test.lib import (
22+
from test.lib import (
2323
TestBase,
2424
fixture_path
2525
)
26-
from git.test.lib import with_rw_directory
26+
from test.lib import with_rw_directory
2727
from git.util import finalize_process
2828

2929
import os.path as osp

Diff for: git/test/test_index.py renamed to test/test_index.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
IndexEntry
3737
)
3838
from git.objects import Blob
39-
from git.test.lib import (
39+
from test.lib import (
4040
TestBase,
4141
fixture_path,
4242
fixture,
4343
with_rw_repo
4444
)
45-
from git.test.lib import with_rw_directory
45+
from test.lib import with_rw_directory
4646
from git.util import Actor, rmtree
4747
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, hex_to_bin
4848
from gitdb.base import IStream

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")

Diff for: git/test/test_reflog.py renamed to test/test_reflog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
RefLogEntry,
77
RefLog
88
)
9-
from git.test.lib import (
9+
from test.lib import (
1010
TestBase,
1111
fixture_path
1212
)

Diff for: git/test/test_refs.py renamed to test/test_refs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
RefLog
1818
)
1919
from git.objects.tag import TagObject
20-
from git.test.lib import (
20+
from test.lib import (
2121
TestBase,
2222
with_rw_repo
2323
)

Diff for: git/test/test_remote.py renamed to test/test_remote.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
GitCommandError
2323
)
2424
from git.cmd import Git
25-
from git.test.lib import (
25+
from test.lib import (
2626
TestBase,
2727
with_rw_repo,
2828
with_rw_and_rw_remote_repo,

Diff for: git/test/test_repo.py renamed to test/test_repo.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
BadObject,
3737
)
3838
from git.repo.fun import touch
39-
from git.test.lib import (
39+
from test.lib import (
4040
TestBase,
4141
with_rw_repo,
4242
fixture
4343
)
4444
from git.util import HIDE_WINDOWS_KNOWN_ERRORS, cygpath
45-
from git.test.lib import with_rw_directory
45+
from test.lib import with_rw_directory
4646
from git.util import join_path_native, rmtree, rmfile, bin_to_hex
4747

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

Diff for: git/test/test_stats.py renamed to test/test_stats.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This module is part of GitPython and is released under
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

7-
from git.test.lib import (
7+
from test.lib import (
88
TestBase,
99
fixture
1010
)

0 commit comments

Comments
 (0)