FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GitPython/test/test_installation.py at main · gitpython-developers/GitPython · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
gitpython-developers
/
GitPython
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
989
Star
5.2k
Code
Issues
8
Pull requests
2
Discussions
Actions
Security and quality
34
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
GitPython
/
test
/
test_installation.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (61 loc) · 2.59 KB
Breadcrumbs
GitPython
/
test
/
test_installation.py
Copy path
File metadata and controls
75 lines (61 loc) · 2.59 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# This module is part of GitPython and is released under the
# 3-Clause BSD License: https://opensource.org/license/bsd-3-clause/
import
ast
import
functools
import
os
import
subprocess
from
test
.
lib
import
TestBase
,
VirtualEnvironment
,
requires_symlinks
,
with_rw_directory
class
TestInstallation
(
TestBase
):
@
requires_symlinks
@
with_rw_directory
def
test_installation
(
self
,
rw_dir
):
venv
,
run
=
self
.
_set_up_venv
(
rw_dir
)
for
project
in
(
"./smmap"
,
"./gitdb"
,
"."
):
result
=
run
([
venv
.
pip
,
"install"
,
project
])
self
.
_check_result
(
result
,
f"Can't install
{
project
}
"
)
result
=
run
([
venv
.
python
,
"-c"
,
"import git"
])
self
.
_check_result
(
result
,
"Self-test failed"
)
result
=
run
([
venv
.
python
,
"-c"
,
"import gitdb; import smmap"
])
self
.
_check_result
(
result
,
"Dependencies not installed"
)
# Even IF gitdb or any other dependency is supplied during development by
# inserting its location into PYTHONPATH or otherwise patched into sys.path,
# make sure it is not wrongly inserted as the *first* entry.
result
=
run
([
venv
.
python
,
"-c"
,
"import sys; import git; print(sys.path)"
])
syspath
=
result
.
stdout
.
splitlines
()[
0
]
syspath
=
ast
.
literal_eval
(
syspath
)
self
.
assertEqual
(
""
,
syspath
[
0
],
msg
=
"Failed to follow the conventions for https://docs.python.org/3/library/sys.html#sys.path"
,
)
@
staticmethod
def
_set_up_venv
(
rw_dir
):
# Initialize the virtual environment.
venv
=
VirtualEnvironment
(
rw_dir
,
with_pip
=
True
)
# Make its src directory a symlink to our own top-level source tree.
os
.
symlink
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
)),
venv
.
sources
,
target_is_directory
=
True
,
)
# Create a convenience function to run commands in it.
run
=
functools
.
partial
(
subprocess
.
run
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
universal_newlines
=
True
,
cwd
=
venv
.
sources
,
env
=
{
**
os
.
environ
,
"PYTHONWARNINGS"
:
"error"
},
)
return
venv
,
run
def
_check_result
(
self
,
result
,
failure_summary
):
self
.
assertEqual
(
0
,
result
.
returncode
,
msg
=
self
.
_prepare_failure_message
(
result
,
failure_summary
),
)
@
staticmethod
def
_prepare_failure_message
(
result
,
failure_summary
):
stdout
=
result
.
stdout
.
rstrip
()
stderr
=
result
.
stderr
.
rstrip
()
return
f"
{
failure_summary
}
\n
\n
stdout:
\n
{
stdout
}
\n
\n
stderr:
\n
{
stderr
}
"
Back
|
FazBrowse Home
|
New Git URL