Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
gevent
Commits
0c13bd51
Commit
0c13bd51
authored
May 02, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for copy(gevent.local.local instance). Patch by Galfy Pundee.
parent
ad0aa9a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
+57
-0
greentest/test__local.py
greentest/test__local.py
+57
-0
No files found.
greentest/test__local.py
0 → 100644
View file @
0c13bd51
import
unittest
from
copy
import
copy
# Comment the line below to see that the standard thread.local is working correct
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
threading
import
local
class
A
(
local
):
__slots__
=
[
'initialized'
,
'obj'
]
path
=
''
def
__init__
(
self
,
obj
):
if
not
hasattr
(
self
,
'initialized'
):
self
.
obj
=
obj
self
.
path
=
''
class
Obj
(
object
):
pass
class
GeventLocalTestCase
(
unittest
.
TestCase
):
def
test_copy
(
self
):
a
=
A
(
Obj
())
a
.
path
=
'123'
a
.
obj
.
echo
=
'test'
b
=
copy
(
a
)
"""
Copy makes a shallow copy. Meaning that the attribute path
has to be independent in the original and the copied object because the
value is a string, but the attribute obj should be just reference to
the instance of the class Obj
"""
self
.
assertEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be equal'
)
self
.
assertEqual
(
a
.
obj
,
b
.
obj
,
'The values must be equal'
)
b
.
path
=
'321'
self
.
assertNotEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be different'
)
a
.
obj
.
echo
=
"works"
self
.
assertEqual
(
a
.
obj
,
b
.
obj
,
'The values must be equal'
)
def
test_objects
(
self
):
"""
Test which failed in the eventlet?!
"""
a
=
A
({})
a
.
path
=
'123'
b
=
A
({
'one'
:
2
})
b
.
path
=
'123'
self
.
assertEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be equal'
)
b
.
path
=
'321'
self
.
assertNotEqual
(
a
.
path
,
b
.
path
,
'The values in the two objects must be different'
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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