FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
GitPython/git/test/test_exc.py at no_devnull_open · og-python-scripts/GitPython · GitHub
og-python-scripts
GitPython
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
GitPython
/
git
/
test
/
test_exc.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
142 lines (119 loc) · 4.21 KB
Breadcrumbs
GitPython
/
git
/
test
/
test_exc.py
Copy path
File metadata and controls
142 lines (119 loc) · 4.21 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# -*- coding: utf-8 -*-
# test_exc.py
# Copyright (C) 2008, 2009, 2016 Michael Trier (mtrier@gmail.com) and contributors
#
# This module is part of GitPython and is released under
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
import
re
import
ddt
from
git
.
exc
import
(
CommandError
,
GitCommandNotFound
,
GitCommandError
,
HookExecutionError
,
)
from
git
.
test
.
lib
import
TestBase
import
itertools
as
itt
_cmd_argvs
=
(
(
'cmd'
, ),
(
'θνιψοδε'
, ),
(
'θνιψοδε'
,
'normal'
,
'argvs'
),
(
'cmd'
,
'ελληνικα'
,
'args'
),
(
'θνιψοδε'
,
'κι'
,
'αλλα'
,
'strange'
,
'args'
),
(
'θνιψοδε'
,
'κι'
,
'αλλα'
,
'non-unicode'
,
'args'
),
)
_causes_n_substrings
=
(
(
None
,
None
),
# noqa: E241 @IgnorePep8
(
7
,
"exit code(7)"
),
# noqa: E241 @IgnorePep8
(
'Some string'
,
"'Some string'"
),
# noqa: E241 @IgnorePep8
(
'παλιο string'
,
"'παλιο string'"
),
# noqa: E241 @IgnorePep8
(
Exception
(
"An exc."
),
"Exception('An exc.')"
),
# noqa: E241 @IgnorePep8
(
Exception
(
"Κακια exc."
),
"Exception('Κακια exc.')"
),
# noqa: E241 @IgnorePep8
(
object
(),
"<object object at "
),
# noqa: E241 @IgnorePep8
)
_streams_n_substrings
=
(
None
,
'steram'
,
'ομορφο stream'
, )
@
ddt
.
ddt
class
TExc
(
TestBase
):
@
ddt
.
data
(
*
list
(
itt
.
product
(
_cmd_argvs
,
_causes_n_substrings
,
_streams_n_substrings
)))
def
test_CommandError_unicode
(
self
,
case
):
argv
, (
cause
,
subs
),
stream
=
case
cls
=
CommandError
c
=
cls
(
argv
,
cause
)
s
=
str
(
c
)
self
.
assertIsNotNone
(
c
.
_msg
)
self
.
assertIn
(
' cmdline: '
,
s
)
for
a
in
argv
:
self
.
assertIn
(
a
,
s
)
if
not
cause
:
self
.
assertIn
(
"failed!"
,
s
)
else
:
self
.
assertIn
(
" failed due to:"
,
s
)
if
subs
is
not
None
:
# Substrings (must) already contain opening `'`.
subs
=
"(?<!')%s(?!')"
%
re
.
escape
(
subs
)
self
.
assertRegexpMatches
(
s
,
subs
)
if
not
stream
:
c
=
cls
(
argv
,
cause
)
s
=
str
(
c
)
self
.
assertNotIn
(
" stdout:"
,
s
)
self
.
assertNotIn
(
" stderr:"
,
s
)
else
:
c
=
cls
(
argv
,
cause
,
stream
)
s
=
str
(
c
)
self
.
assertIn
(
" stderr:"
,
s
)
self
.
assertIn
(
stream
,
s
)
c
=
cls
(
argv
,
cause
,
None
,
stream
)
s
=
str
(
c
)
self
.
assertIn
(
" stdout:"
,
s
)
self
.
assertIn
(
stream
,
s
)
c
=
cls
(
argv
,
cause
,
stream
,
stream
+
'no2'
)
s
=
str
(
c
)
self
.
assertIn
(
" stderr:"
,
s
)
self
.
assertIn
(
stream
,
s
)
self
.
assertIn
(
" stdout:"
,
s
)
self
.
assertIn
(
stream
+
'no2'
,
s
)
@
ddt
.
data
(
([
'cmd1'
],
None
),
([
'cmd1'
],
"some cause"
),
([
'cmd1'
],
Exception
()),
)
def
test_GitCommandNotFound
(
self
,
init_args
):
argv
,
cause
=
init_args
c
=
GitCommandNotFound
(
argv
,
cause
)
s
=
str
(
c
)
self
.
assertIn
(
argv
[
0
],
s
)
if
cause
:
self
.
assertIn
(
' not found due to: '
,
s
)
self
.
assertIn
(
str
(
cause
),
s
)
else
:
self
.
assertIn
(
' not found!'
,
s
)
@
ddt
.
data
(
([
'cmd1'
],
None
),
([
'cmd1'
],
"some cause"
),
([
'cmd1'
],
Exception
()),
)
def
test_GitCommandError
(
self
,
init_args
):
argv
,
cause
=
init_args
c
=
GitCommandError
(
argv
,
cause
)
s
=
str
(
c
)
self
.
assertIn
(
argv
[
0
],
s
)
if
cause
:
self
.
assertIn
(
' failed due to: '
,
s
)
self
.
assertIn
(
str
(
cause
),
s
)
else
:
self
.
assertIn
(
' failed!'
,
s
)
@
ddt
.
data
(
([
'cmd1'
],
None
),
([
'cmd1'
],
"some cause"
),
([
'cmd1'
],
Exception
()),
)
def
test_HookExecutionError
(
self
,
init_args
):
argv
,
cause
=
init_args
c
=
HookExecutionError
(
argv
,
cause
)
s
=
str
(
c
)
self
.
assertIn
(
argv
[
0
],
s
)
if
cause
:
self
.
assertTrue
(
s
.
startswith
(
'Hook('
),
s
)
self
.
assertIn
(
str
(
cause
),
s
)
else
:
self
.
assertIn
(
' failed!'
,
s
)
Back
|
FazBrowse Home
|
New Git URL