Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lettuce
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
edx
lettuce
Commits
ac60d5dc
Commit
ac60d5dc
authored
Jan 24, 2013
by
Gabriel Falcao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://github.com/pshomov/lettuce
into pshomov-master
Conflicts: lettuce/plugins/xunit_output.py closes #305
parents
afbcab57
79e52bf4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
10 deletions
+69
-10
lettuce/plugins/xunit_output.py
+13
-10
lettuce/strings.py
+8
-0
tests/functional/output_features/missing_steps/missing_steps.feature
+3
-0
tests/functional/output_features/unicode_traceback/unicode_traceback.feature
+6
-0
tests/functional/output_features/unicode_traceback/unicode_traceback_steps.py
+10
-0
tests/functional/test_xunit_output.py
+29
-0
No files found.
lettuce/plugins/xunit_output.py
View file @
ac60d5dc
...
...
@@ -15,10 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
datetime
import
datetime
from
datetime
import
datetime
,
timedelta
from
lettuce.terrain
import
after
from
lettuce.terrain
import
before
from
xml.dom
import
minidom
from
lettuce.strings
import
utf8_bytestring
def
wrt_output
(
filename
,
content
):
...
...
@@ -52,24 +53,26 @@ def enable(filename=None):
if
step
.
scenario
.
outlines
:
return
classname
=
"
%
s :
%
s"
%
(
step
.
scenario
.
feature
.
name
,
step
.
scenario
.
name
)
classname
=
utf8_bytestring
(
u"
%
s :
%
s"
%
(
step
.
scenario
.
feature
.
name
,
step
.
scenario
.
name
)
)
tc
=
doc
.
createElement
(
"testcase"
)
tc
.
setAttribute
(
"classname"
,
classname
)
tc
.
setAttribute
(
"name"
,
step
.
sentence
)
if
step
.
ran
:
tc
.
setAttribute
(
"name"
,
step
.
sentence
.
encode
(
'utf-8'
)
)
try
:
tc
.
setAttribute
(
"time"
,
str
(
total_seconds
((
datetime
.
now
()
-
step
.
started
))))
else
:
tc
.
setAttribute
(
"time"
,
str
(
0
))
skip
=
doc
.
createElement
(
"skipped"
)
except
AttributeError
:
tc
.
setAttribute
(
"time"
,
str
(
total_seconds
(
timedelta
(
seconds
=
0
))))
if
not
step
.
ran
:
skip
=
doc
.
createElement
(
"skipped"
)
skip
.
setAttribute
(
"type"
,
"UndefinedStep(
%
s)"
%
step
.
sentence
)
tc
.
appendChild
(
skip
)
if
step
.
failed
:
cdata
=
doc
.
createCDATASection
(
step
.
why
.
traceback
)
cdata
=
doc
.
createCDATASection
(
step
.
why
.
traceback
.
encode
(
'utf-8'
)
)
failure
=
doc
.
createElement
(
"failure"
)
if
hasattr
(
step
.
why
,
'cause'
):
failure
.
setAttribute
(
"message"
,
step
.
why
.
cause
)
failure
.
setAttribute
(
"type"
,
step
.
why
.
exception
.
__class__
.
__name__
)
failure
.
setAttribute
(
"message"
,
step
.
why
.
cause
.
encode
(
'utf-8'
)
)
failure
.
setAttribute
(
"type"
,
step
.
why
.
exception
.
__class__
.
__name__
.
encode
(
'utf-8'
)
)
failure
.
appendChild
(
cdata
)
tc
.
appendChild
(
failure
)
...
...
lettuce/strings.py
View file @
ac60d5dc
...
...
@@ -20,6 +20,14 @@ import time
import
unicodedata
def
utf8_bytestring
(
s
):
if
isinstance
(
s
,
str
):
s
=
s
.
decode
(
"utf-8"
)
elif
isinstance
(
s
,
unicode
):
s
=
s
.
encode
(
"utf-8"
)
return
s
def
escape_if_necessary
(
what
):
what
=
unicode
(
what
)
if
len
(
what
)
is
1
:
...
...
tests/functional/output_features/missing_steps/missing_steps.feature
0 → 100644
View file @
ac60d5dc
Feature
:
Missing steps do not cause the xunit plugin to throw
Scenario
:
It should pass
Given
my sdfsdf sdfsdf sdfs df sdfsdf
tests/functional/output_features/unicode_traceback/unicode_traceback.feature
0 → 100644
View file @
ac60d5dc
Feature
:
Unicode characters in the error traceback
Scenario
:
It should pass
Given
my dæmi that passes
Scenario
:
It should raise an exception different of AssertionError
Given
my
"dæmi"
that blows an exception
tests/functional/output_features/unicode_traceback/unicode_traceback_steps.py
0 → 100644
View file @
ac60d5dc
# -*- coding: utf-8 -*-
from
lettuce
import
step
@step
(
u'my dæmi that passes'
)
def
given_my_daemi_that_passes
(
step
,
d
):
step
.
given
(
u'my "INNSKRÁ" that blows a exception'
)
@step
(
'my "(.*)" that blows an exception'
)
def
given_my_daemi_that_blows_a_exception
(
step
,
name
):
assert
False
tests/functional/test_xunit_output.py
View file @
ac60d5dc
...
...
@@ -105,6 +105,35 @@ def test_xunit_output_with_different_filename():
assert_equals
(
1
,
len
(
called
),
"Function not called"
)
xunit_output
.
wrt_output
=
old
@with_setup
(
prepare_stdout
,
registry
.
clear
)
def
test_xunit_output_with_unicode_characters_in_error_messages
():
called
=
[]
def
assert_correct_xml
(
filename
,
content
):
called
.
append
(
True
)
assert_xsd_valid
(
filename
,
content
)
old
=
xunit_output
.
wrt_output
xunit_output
.
wrt_output
=
assert_correct_xml
runner
=
Runner
(
feature_name
(
'unicode_traceback'
),
enable_xunit
=
True
,
xunit_filename
=
"custom_filename.xml"
)
runner
.
run
()
assert_equals
(
1
,
len
(
called
),
"Function not called"
)
xunit_output
.
wrt_output
=
old
@with_setup
(
prepare_stdout
,
registry
.
clear
)
def
test_xunit_does_not_throw_exception_when_missing_step_definition
():
def
dummy_write
(
filename
,
content
):
pass
old
=
xunit_output
.
wrt_output
xunit_output
.
wrt_output
=
dummy_write
runner
=
Runner
(
feature_name
(
'missing_steps'
),
enable_xunit
=
True
,
xunit_filename
=
"mising_steps.xml"
)
runner
.
run
()
xunit_output
.
wrt_output
=
old
@with_setup
(
prepare_stdout
,
registry
.
clear
)
def
test_xunit_output_with_no_steps
():
...
...
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