Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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.core
Commits
b67509f5
Commit
b67509f5
authored
Jun 15, 2023
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testing: Factor snapshot management
parent
6f9e279e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
12 deletions
+22
-12
slapos/testing/testcase.py
slapos/testing/testcase.py
+22
-12
No files found.
slapos/testing/testcase.py
View file @
b67509f5
...
...
@@ -26,12 +26,13 @@
#
##############################################################################
import
unittest
import
os
import
contextlib
import
fnmatch
import
glob
import
logging
import
os
import
shutil
import
unittest
import
warnings
from
six.moves.urllib.parse
import
urlparse
...
...
@@ -410,23 +411,32 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls
.
slap
.
_instance_root
,
cls
.
computer_partition
.
getId
())
@
classmethod
def
setUpClass
(
cls
):
"""Request an instance.
"""
cls
.
logger
.
debug
(
"Starting setUpClass %s"
,
cls
)
cls
.
_instance_parameter_dict
=
cls
.
getInstanceParameterDict
()
snapshot_name
=
"{}.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
)
@
contextlib
.
contextmanager
def
_snapshotManager
(
cls
,
snapshot_name
):
try
:
cls
.
_setUpClass
()
yield
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
cls
.
_storeSystemSnapshot
(
snapshot_name
)
cls
.
_cleanup
(
snapshot_name
)
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
else
:
cls
.
_storeSystemSnapshot
(
snapshot_name
)
@
classmethod
def
setUpClass
(
cls
):
"""Request an instance.
"""
cls
.
logger
.
debug
(
"Starting setUpClass %s"
,
cls
)
cls
.
_instance_parameter_dict
=
cls
.
getInstanceParameterDict
()
snapshot_name
=
"{}.{}.setUpClass"
.
format
(
cls
.
__module__
,
cls
.
__name__
)
with
cls
.
_snapshotManager
(
snapshot_name
):
try
:
cls
.
_setUpClass
()
except
BaseException
:
cls
.
logger
.
exception
(
"Error during setUpClass"
)
cls
.
setUp
=
lambda
self
:
self
.
fail
(
'Setup Class failed.'
)
raise
cls
.
logger
.
debug
(
"setUpClass done"
)
@
classmethod
...
...
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