Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
c190a0d7
...
c190a0d7755e70fff6e2cb1f7dfab1e4040c4554
authored
2013-02-24 11:29:03 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added clitest for failing test
1 parent
da721e3d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
tests/clitests/runtests.py
tests/clitests/runtests.py
View file @
c190a0d
...
...
@@ -36,20 +36,27 @@ class CasperExecTest(unittest.TestCase):
with
open
(
os
.
path
.
join
(
CASPERJS_ROOT
,
'package.json'
))
as
f
:
self
.
pkg_version
=
json
.
load
(
f
)
.
get
(
'version'
)
def
runCommand
(
self
,
cmd
):
def
runCommand
(
self
,
cmd
,
**
kwargs
):
failing
=
kwargs
.
get
(
'failing'
,
False
)
cmd_args
=
[
CASPER_EXEC
,
'--no-colors'
]
+
cmd
.
split
(
' '
)
try
:
return
subprocess
.
check_output
(
cmd_args
)
.
strip
()
if
failing
:
raise
AssertionError
(
'Command
%
s has not failed'
%
cmd
)
except
subprocess
.
CalledProcessError
as
err
:
raise
IOError
(
'Command
%
s exited with status
%
s'
%
(
cmd
,
err
.
status
))
if
failing
:
return
err
.
output
else
:
raise
IOError
(
'Command
%
s exited with status
%
s'
%
(
cmd
,
err
.
errorcode
))
def
assertCommandOutputEquals
(
self
,
cmd
,
result
):
def
assertCommandOutputEquals
(
self
,
cmd
,
result
,
**
kwargs
):
self
.
assertEquals
(
self
.
runCommand
(
cmd
),
result
)
def
assertCommandOutputContains
(
self
,
cmd
,
what
):
def
assertCommandOutputContains
(
self
,
cmd
,
what
,
**
kwargs
):
if
isinstance
(
what
,
(
list
,
tuple
)):
for
entry
in
what
:
self
.
assertIn
(
entry
,
self
.
runCommand
(
cmd
))
self
.
assertIn
(
entry
,
self
.
runCommand
(
cmd
,
**
kwargs
))
else
:
self
.
assertIn
(
what
,
self
.
runCommand
(
cmd
))
...
...
@@ -97,5 +104,22 @@ class CasperExecTest(unittest.TestCase):
'0 failed'
,
])
@timeout
(
20
)
def
test_new_failing_test
(
self
):
# using begin()
script_path
=
os
.
path
.
join
(
TEST_ROOT
,
'tester'
,
'failing.js'
)
self
.
assertCommandOutputContains
(
'test '
+
script_path
,
[
script_path
,
'# true'
,
'FAIL Subject is strictly true'
,
'# type: assert'
,
'# file:
%
s:3'
%
script_path
,
'# code: test.assert(false);'
,
'# subject: false'
,
'FAIL 1 tests executed'
,
'0 passed'
,
'1 failed.'
,
],
failing
=
True
)
if
__name__
==
'__main__'
:
unittest
.
main
()
...
...
Please
register
or
sign in
to post a comment