Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.cmmi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
slapos.recipe.cmmi
Commits
b1b624aa
Commit
b1b624aa
authored
Mar 29, 2013
by
Kai Lautaportti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rephrased the tests.
parent
6f489532
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
12 deletions
+26
-12
hexagonit/recipe/cmmi/tests.py
hexagonit/recipe/cmmi/tests.py
+21
-12
tox.ini
tox.ini
+5
-0
No files found.
hexagonit/recipe/cmmi/tests.py
View file @
b1b624aa
...
...
@@ -7,11 +7,15 @@ import shutil
import
stat
import
tarfile
import
tempfile
import
unittest
import
zc.buildout
import
zc.buildout.testing
import
zc.buildout.tests
try
:
import
unittest2
as
unittest
except
ImportError
:
import
unittest
optionflags
=
(
doctest
.
ELLIPSIS
|
doctest
.
NORMALIZE_WHITESPACE
|
doctest
.
REPORT_ONLY_FIRST_FAILURE
)
...
...
@@ -65,8 +69,9 @@ class NonInformativeTests(unittest.TestCase):
recipe
=
self
.
make_recipe
({},
'test'
,
{
'path'
:
compile_directory
})
os
.
chdir
(
self
.
dir
)
self
.
assertRaises
(
zc
.
buildout
.
UserError
,
recipe
.
install
)
self
.
assertEquals
(
self
.
dir
,
os
.
getcwd
())
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
):
recipe
.
install
()
self
.
assertEqual
(
self
.
dir
,
os
.
getcwd
())
def
test_working_directory_restored_after_success
(
self
):
compile_directory
=
os
.
path
.
join
(
self
.
dir
,
'compile_directory'
)
...
...
@@ -75,7 +80,7 @@ class NonInformativeTests(unittest.TestCase):
self
.
make_recipe
({},
'test'
,
{
'path'
:
compile_directory
})
os
.
chdir
(
self
.
dir
)
self
.
assertEqual
s
(
self
.
dir
,
os
.
getcwd
())
self
.
assertEqual
(
self
.
dir
,
os
.
getcwd
())
def
test_compile_directory_exists
(
self
):
"""
...
...
@@ -90,7 +95,8 @@ class NonInformativeTests(unittest.TestCase):
# if compile directory exists, recipe should raise an IOError because
# of the bad URL, and _not_ some OSError because test__compile__
# already exists
self
.
assertRaises
(
IOError
,
recipe
.
install
)
with
self
.
assertRaises
(
IOError
):
recipe
.
install
()
def
test_restart_after_failure
(
self
):
temp_directory
=
tempfile
.
mkdtemp
(
dir
=
self
.
dir
,
prefix
=
"fake_package"
)
...
...
@@ -113,10 +119,12 @@ class NonInformativeTests(unittest.TestCase):
try
:
# expected failure
self
.
assertRaises
(
zc
.
buildout
.
UserError
,
recipe
.
install
)
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
):
recipe
.
install
()
# the install should still fail, and _not_ raise an OSError
self
.
assertRaises
(
zc
.
buildout
.
UserError
,
recipe
.
install
)
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
):
recipe
.
install
()
finally
:
try
:
shutil
.
rmtree
(
temp_directory
)
...
...
@@ -131,7 +139,7 @@ class NonInformativeTests(unittest.TestCase):
# Place a sentinel value to make sure the original environment is
# maintained
os
.
environ
[
'HRC_SENTINEL'
]
=
'sentinel'
self
.
assertEqual
s
(
os
.
environ
.
get
(
'HRC_SENTINEL'
),
'sentinel'
)
self
.
assertEqual
(
os
.
environ
.
get
(
'HRC_SENTINEL'
),
'sentinel'
)
recipe
=
self
.
make_recipe
({},
'test'
,
{
'url'
:
'file://%s/testdata/package-0.0.0.tar.gz'
%
os
.
path
.
dirname
(
__file__
),
...
...
@@ -144,12 +152,13 @@ class NonInformativeTests(unittest.TestCase):
self
.
failIf
(
'HRC_FOO'
in
os
.
environ
)
self
.
failIf
(
'HRC_BAR'
in
os
.
environ
)
# Make sure the sentinel value is still in the environment
self
.
assertEqual
s
(
os
.
environ
.
get
(
'HRC_SENTINEL'
),
'sentinel'
)
self
.
assertEqual
(
os
.
environ
.
get
(
'HRC_SENTINEL'
),
'sentinel'
)
def
test_run__unknown_command
(
self
):
recipe
=
self
.
make_recipe
({},
'test'
,
{
'url'
:
'file://%s/testdata/package-0.0.0.tar.gz'
%
os
.
path
.
dirname
(
__file__
)})
self
.
assertRaises
(
zc
.
buildout
.
UserError
,
lambda
:
recipe
.
run
(
'this-command-does-not-exist'
))
with
self
.
assertRaises
(
zc
.
buildout
.
UserError
):
recipe
.
run
(
'this-command-does-not-exist'
)
def
test_call_script__bbb_for_callable_with_two_parameters
(
self
):
recipe
=
self
.
make_recipe
({},
'test'
,
{
...
...
@@ -167,7 +176,7 @@ class NonInformativeTests(unittest.TestCase):
recipe
.
call_script
(
'%s:my_hook'
%
filename
)
self
.
fail
(
"The hook script was not called."
)
except
ValueError
as
e
:
self
.
assertEqual
s
(
str
(
e
),
'I got called'
)
self
.
assertEqual
(
str
(
e
),
'I got called'
)
def
test_call_script__augmented_environment_as_third_parameter
(
self
):
os
.
environ
[
'HRC_SENTINEL'
]
=
'sentinel'
...
...
@@ -189,7 +198,7 @@ class NonInformativeTests(unittest.TestCase):
recipe
.
call_script
(
'%s:my_hook'
%
filename
)
self
.
fail
(
"The hook script was not called."
)
except
ValueError
as
e
:
self
.
assertEqual
s
(
str
(
e
),
'sentinel bar'
)
self
.
assertEqual
(
str
(
e
),
'sentinel bar'
)
def
test_suite
():
...
...
tox.ini
View file @
b1b624aa
...
...
@@ -11,6 +11,11 @@ commands = python setup.py test
deps
=
zc.buildout
=
=1.6.3
[testenv:py26]
deps
=
zc.buildout
=
=1.6.3
unittest2
[testenv:py32]
deps
=
zc.buildout
=
=2.0.0
...
...
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