FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
git2cpp/test/test_add.py at main · QuantStack/git2cpp · GitHub
QuantStack
git2cpp
Repository navigation
Code
Issues
6
(6)
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
git2cpp
/
test
/
test_add.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (34 loc) · 1.39 KB
Breadcrumbs
git2cpp
/
test
/
test_add.py
Copy path
File metadata and controls
45 lines (34 loc) · 1.39 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
import
subprocess
import
pytest
@
pytest
.
mark
.
parametrize
(
"all_flag"
, [
""
,
"-A"
,
"--all"
,
"--no-ignore-removal"
])
def
test_add
(
git2cpp_path
,
tmp_path
,
all_flag
):
cmd_init
=
[
git2cpp_path
,
"init"
,
"."
]
p_init
=
subprocess
.
run
(
cmd_init
,
capture_output
=
True
,
cwd
=
tmp_path
)
assert
p_init
.
returncode
==
0
p
=
tmp_path
/
"mook_file.txt"
p
.
write_text
(
""
)
p2
=
tmp_path
/
"mook_file_2.txt"
p2
.
write_text
(
""
)
cmd_add
=
[
git2cpp_path
,
"add"
]
if
all_flag
!=
""
:
cmd_add
.
append
(
all_flag
)
else
:
cmd_add
.
append
(
"mook_file.txt"
)
p_add
=
subprocess
.
run
(
cmd_add
,
cwd
=
tmp_path
,
text
=
True
)
assert
p_add
.
returncode
==
0
cmd_status
=
[
git2cpp_path
,
"status"
,
"--long"
]
p_status
=
subprocess
.
run
(
cmd_status
,
cwd
=
tmp_path
,
capture_output
=
True
,
text
=
True
)
assert
p_status
.
returncode
==
0
assert
"Changes to be committed"
in
p_status
.
stdout
assert
"new file"
in
p_status
.
stdout
if
all_flag
!=
""
:
assert
"Untracked files"
not
in
p_status
.
stdout
else
:
assert
"Untracked files"
in
p_status
.
stdout
def
test_add_nogit
(
git2cpp_path
,
tmp_path
):
p
=
tmp_path
/
"mook_file.txt"
p
.
write_text
(
""
)
cmd_add
=
[
git2cpp_path
,
"add"
,
"mook_file.txt"
]
p_add
=
subprocess
.
run
(
cmd_add
,
cwd
=
tmp_path
,
text
=
True
,
capture_output
=
True
)
assert
p_add
.
returncode
!=
0
assert
"error: could not find repository at"
in
p_add
.
stderr
Back
|
FazBrowse Home
|
New Git URL