Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
e2a48b66
Commit
e2a48b66
authored
Apr 13, 2014
by
Damien George
Browse files
tests: Add property test.
parent
777b0f32
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/basics/property.py
0 → 100644
View file @
e2a48b66
class
A
:
def
__init__
(
self
,
x
):
self
.
_x
=
x
@
property
def
x
(
self
):
print
(
"x get"
)
return
self
.
_x
a
=
A
(
1
)
print
(
a
.
x
)
try
:
a
.
x
=
2
except
AttributeError
:
print
(
"AttributeError"
)
class
B
:
def
__init__
(
self
,
x
):
self
.
_x
=
x
def
xget
(
self
):
print
(
"x get"
)
return
self
.
_x
def
xset
(
self
,
value
):
print
(
"x set"
)
self
.
_x
=
value
x
=
property
(
xget
,
xset
)
b
=
B
(
3
)
print
(
b
.
x
)
b
.
x
=
4
print
(
b
.
x
)
class
C
:
def
__init__
(
self
,
x
):
self
.
_x
=
x
@
property
def
x
(
self
):
print
(
"x get"
)
return
self
.
_x
@
x
.
setter
def
x
(
self
,
value
):
print
(
"x set"
)
self
.
_x
=
value
c
=
C
(
5
)
print
(
c
.
x
)
c
.
x
=
6
print
(
c
.
x
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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