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
Xiaowu Zhang
slapos.core
Commits
7a339758
Commit
7a339758
authored
Aug 09, 2011
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test optimisation: Disallow sleeping.
parent
49ba5035
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
+19
-0
slapos/tests/slapformat.py
slapos/tests/slapformat.py
+19
-0
No files found.
slapos/tests/slapformat.py
View file @
7a339758
...
...
@@ -9,6 +9,7 @@ import grp
import
netifaces
import
os
import
pwd
import
time
USER_LIST
=
[]
GROUP_LIST
=
[]
...
...
@@ -67,6 +68,11 @@ class LoggableWrapper:
'%s=%r'
%
(
x
,
y
)
for
x
,
y
in
kwargs
.
iteritems
()]
self
.
__logger
.
debug
(
'%s(%s)'
%
(
self
.
__name
,
', '
.
join
(
arg_list
)))
class
TimeMock
:
@
classmethod
def
sleep
(
self
,
seconds
):
return
class
GrpMock
:
@
classmethod
def
getgrnam
(
self
,
name
):
...
...
@@ -123,6 +129,17 @@ class SlapformatMixin(unittest.TestCase):
setattr
(
pwd
,
name
,
original_value
)
del
self
.
saved_pwd
def
patchTime
(
self
):
self
.
saved_time
=
dict
()
for
fake
in
vars
(
TimeMock
):
self
.
saved_time
[
fake
]
=
getattr
(
time
,
fake
,
None
)
setattr
(
time
,
fake
,
getattr
(
TimeMock
,
fake
))
def
restoreTime
(
self
):
for
name
,
original_value
in
self
.
saved_time
.
items
():
setattr
(
time
,
name
,
original_value
)
del
self
.
saved_time
def
patchGrp
(
self
):
self
.
saved_grp
=
dict
()
for
fake
in
vars
(
GrpMock
):
...
...
@@ -169,12 +186,14 @@ class SlapformatMixin(unittest.TestCase):
slapos
.
format
.
callAndRead
=
self
.
fakeCallAndRead
self
.
patchOs
(
logger
)
self
.
patchGrp
()
self
.
patchTime
()
self
.
patchPwd
()
self
.
patchNetifaces
()
def
tearDown
(
self
):
self
.
restoreOs
()
self
.
restoreGrp
()
self
.
restoreTime
()
self
.
restorePwd
()
self
.
restoreNetifaces
()
slapos
.
format
.
callAndRead
=
self
.
real_callAndRead
...
...
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