Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-platform
Commits
096dca74
Commit
096dca74
authored
Nov 02, 2017
by
Jeremy Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Omit captured output in XML for passing tests
parent
e26f0ed0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
0 deletions
+46
-0
cms/conftest.py
+21
-0
common/lib/conftest.py
+25
-0
No files found.
cms/conftest.py
View file @
096dca74
...
@@ -12,6 +12,26 @@ import importlib
...
@@ -12,6 +12,26 @@ import importlib
import
os
import
os
import
contracts
import
contracts
import
pytest
import
pytest
from
_pytest.junitxml
import
_NodeReporter
,
bin_xml_escape
,
Junit
def
write_captured_output
(
self
,
report
):
"""
Replacement for _NodeReporter.write_captured_output() in the junitxml
pytest plugin. Only outputs the captured stderr and stdout streams
for failing tests, which dramatically reduces the size of the
generated XML file.
A cleaner fix has been proposed at https://github.com/pytest-dev/pytest/issues/2889
"""
failed
=
any
([
node
for
node
in
self
.
nodes
if
node
.
__class__
.
__name__
!=
'py._xmlgen.skipped'
])
if
not
failed
:
return
for
capname
in
(
'out'
,
'err'
):
content
=
getattr
(
report
,
'capstd'
+
capname
)
if
content
:
tag
=
getattr
(
Junit
,
'system-'
+
capname
)
self
.
append
(
tag
(
bin_xml_escape
(
content
)))
def
pytest_configure
(
config
):
def
pytest_configure
(
config
):
...
@@ -20,6 +40,7 @@ def pytest_configure(config):
...
@@ -20,6 +40,7 @@ def pytest_configure(config):
"""
"""
if
config
.
getoption
(
'help'
):
if
config
.
getoption
(
'help'
):
return
return
_NodeReporter
.
write_captured_output
=
write_captured_output
enable_contracts
=
os
.
environ
.
get
(
'ENABLE_CONTRACTS'
,
False
)
enable_contracts
=
os
.
environ
.
get
(
'ENABLE_CONTRACTS'
,
False
)
if
not
enable_contracts
:
if
not
enable_contracts
:
contracts
.
disable_all
()
contracts
.
disable_all
()
...
...
common/lib/conftest.py
View file @
096dca74
"""
common/lib unit test configuration.
"""
from
django.conf
import
settings
from
django.conf
import
settings
from
_pytest.junitxml
import
_NodeReporter
,
bin_xml_escape
,
Junit
def
write_captured_output
(
self
,
report
):
"""
Replacement for _NodeReporter.write_captured_output() in the junitxml
pytest plugin. Only outputs the captured stderr and stdout streams
for failing tests, which dramatically reduces the size of the
generated XML file.
A cleaner fix has been proposed at https://github.com/pytest-dev/pytest/issues/2889
"""
failed
=
any
([
node
for
node
in
self
.
nodes
if
node
.
__class__
.
__name__
!=
'py._xmlgen.skipped'
])
if
not
failed
:
return
for
capname
in
(
'out'
,
'err'
):
content
=
getattr
(
report
,
'capstd'
+
capname
)
if
content
:
tag
=
getattr
(
Junit
,
'system-'
+
capname
)
self
.
append
(
tag
(
bin_xml_escape
(
content
)))
def
pytest_configure
():
def
pytest_configure
():
...
@@ -6,3 +30,4 @@ def pytest_configure():
...
@@ -6,3 +30,4 @@ def pytest_configure():
Use Django's default settings for tests in common/lib.
Use Django's default settings for tests in common/lib.
"""
"""
settings
.
configure
()
settings
.
configure
()
_NodeReporter
.
write_captured_output
=
write_captured_output
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