Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_coverage_plugin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5_coverage_plugin
Commits
1d1e6c7f
Commit
1d1e6c7f
authored
Nov 19, 2022
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support python2 in test
parent
80a38d1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
tests/test_integration.py
tests/test_integration.py
+8
-8
No files found.
tests/test_integration.py
View file @
1d1e6c7f
...
...
@@ -13,7 +13,7 @@ import pytest
def
file_system_script
(
tmp_path
):
p
=
tmp_path
/
'script.py'
p
.
write_text
(
'''
\
u
'''
\
if "a" == "a" and "b" == "c":
_ = 1 / 0 # will not be covered
...
...
@@ -28,7 +28,7 @@ return 'returned value'
@
contextlib
.
contextmanager
def
_coverage_process
(
file_system_script
,
branch
):
cwd
=
os
.
getcwd
()
os
.
chdir
(
file_system_script
.
parent
)
os
.
chdir
(
str
(
file_system_script
.
parent
)
)
cp
=
coverage
.
Coverage
(
include
=
[
'./*'
],
branch
=
branch
)
cp
.
set_option
(
'run:plugins'
,
[
'erp5_coverage_plugin'
])
cp
.
start
()
...
...
@@ -56,14 +56,14 @@ def python_script(file_system_script):
# script
ps
.
_erp5_coverage_filename
=
str
(
file_system_script
.
absolute
())
ps
.
ZPythonScript_edit
(
''
,
file_system_script
.
read_text
())
ps
.
ZPythonScript_edit
(
''
,
file_system_script
.
open
())
yield
ps
.
__of__
(
makerequest
(
DummyFolder
(
'folder'
)))
@
pytest
.
fixture
()
def
python_script_with_callback
(
file_system_script
):
file_system_script
.
write_text
(
'''
\
u
'''
\
result_storage = []
def callback_function(result):
result_storage.append(result)
...
...
@@ -73,7 +73,7 @@ return result_storage
source_code_folder
=
file_system_script
.
parent
callback_file_system_script
=
source_code_folder
/
'callback.py'
callback_file_system_script
.
write_text
(
'''
\
u
'''
\
callback_function("returned value")
'''
)
...
...
@@ -85,9 +85,9 @@ callback_function("returned value")
test_script
.
_erp5_coverage_filename
=
str
(
file_system_script
.
absolute
())
callback_script
.
_erp5_coverage_filename
=
str
(
callback_file_system_script
.
absolute
())
test_script
.
ZPythonScript_edit
(
''
,
file_system_script
.
read_text
())
test_script
.
ZPythonScript_edit
(
''
,
file_system_script
.
open
())
callback_script
.
ZPythonScript_edit
(
'callback_function'
,
callback_file_system_script
.
read_text
())
'callback_function'
,
callback_file_system_script
.
open
())
folder
=
makerequest
(
DummyFolder
(
'folder'
))
yield
test_script
.
__of__
(
folder
),
callback_script
.
__of__
(
folder
)
...
...
@@ -118,7 +118,7 @@ script.py 4 1 2 1 67%
TOTAL 4 1 2 1 67%
'''
outfile
=
tmp_path
/
'out.json'
assert
coverage_process_with_branch_coverage
.
json_report
(
outfile
=
outfile
)
>
0
assert
coverage_process_with_branch_coverage
.
json_report
(
outfile
=
str
(
outfile
)
)
>
0
script_py_report
=
json
.
loads
(
outfile
.
read_text
())[
'files'
][
'script.py'
]
script_py_report
.
pop
(
'summary'
)
assert
script_py_report
==
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment