Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go123
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go123
Commits
87228e62
Commit
87228e62
authored
Oct 09, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xnet/lonet.py: Use defer
Pygolang, starting from 0.0.0.dev5 provides working defer.
parent
2789db4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
13 deletions
+8
-13
xnet/lonet/lonet_test.py
xnet/lonet/lonet_test.py
+8
-13
No files found.
xnet/lonet/lonet_test.py
View file @
87228e62
...
...
@@ -18,7 +18,7 @@
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from
golang
import
gimport
from
golang
import
gimport
,
defer
,
func
xerr
=
gimport
(
'lab.nexedi.com/kirr/go123/xerr'
)
lonet
=
gimport
(
'lab.nexedi.com/kirr/go123/xnet/lonet'
)
...
...
@@ -41,22 +41,20 @@ def xwrite(sk, data):
# _test_virtnet_basic runs basic tests on a virtnet network implementation.
# (this follows virtnettest.TestBasic)
@
func
def
_test_virtnet_basic
(
subnet
):
# (verifying that error log stays empty)
errorlog
=
StringIO
()
errorlogh
=
log
.
StreamHandler
(
errorlog
)
l
=
log
.
getLogger
()
l
.
addHandler
(
errorlogh
)
try
:
__test_virtnet_basic
(
subnet
)
finally
:
subnet
.
close
()
def
_
():
l
.
removeHandler
(
errorlogh
)
assert
errorlog
.
getvalue
()
==
""
defer
(
_
)
defer
(
subnet
.
close
)
def
__test_virtnet_basic
(
subnet
):
def
xaddr
(
addr
):
return
lonet
.
Addr
.
parse
(
subnet
.
network
(),
addr
)
...
...
@@ -143,14 +141,11 @@ def test_lonet_py_basic():
# test interaction with lonet.go
@
func
def
test_lonet_py_go
(
network
):
subnet
=
lonet
.
join
(
network
)
try
:
_test_lonet_py_go
(
subnet
)
finally
:
subnet
.
close
()
defer
(
subnet
.
close
)
def
_test_lonet_py_go
(
subnet
):
def
xaddr
(
addr
):
return
lonet
.
Addr
.
parse
(
subnet
.
network
(),
addr
)
...
...
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