mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Descriptor tests fixup (3/3)
Better tests for properties
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
| 13 | classmethod() | 14 | Function c1 |
|
||||
| 20 | classmethod() | 17 | Function c2 |
|
||||
| 21 | classmethod() | 17 | Function c2 |
|
||||
| 23 | staticmethod() | 24 | Function s1 |
|
||||
| 30 | staticmethod() | 27 | Function s2 |
|
||||
| 31 | staticmethod() | 27 | Function s2 |
|
||||
| 55 | classmethod() | 56 | Function c1 |
|
||||
| 62 | classmethod() | 59 | Function c2 |
|
||||
| 63 | classmethod() | 59 | Function c2 |
|
||||
| 65 | staticmethod() | 66 | Function s1 |
|
||||
| 72 | staticmethod() | 69 | Function s2 |
|
||||
| 73 | staticmethod() | 69 | Function s2 |
|
||||
|
||||
@@ -1,2 +1,8 @@
|
||||
| test.py:4:5:4:16 | Function f | getter | test.py:3:6:3:13 | Property f |
|
||||
| test.py:8:5:8:23 | Function f | setter | test.py:3:6:3:13 | Property f |
|
||||
| test.py:6:5:6:16 | Function x | getter | test.py:5:6:5:13 | Property x |
|
||||
| test.py:11:5:11:23 | Function x | setter | test.py:5:6:5:13 | Property x |
|
||||
| test.py:15:5:15:16 | Function x | deleter | test.py:5:6:5:13 | Property x |
|
||||
| test.py:21:5:21:16 | Function x | getter | test.py:20:6:20:13 | Property x |
|
||||
| test.py:28:5:28:19 | Function getx | getter | test.py:37:9:37:59 | Property getx |
|
||||
| test.py:31:5:31:26 | Function setx | setter | test.py:37:9:37:59 | Property getx |
|
||||
| test.py:34:5:34:19 | Function delx | deleter | test.py:37:9:37:59 | Property getx |
|
||||
| test.py:41:5:41:19 | Function getx | getter | test.py:44:9:44:22 | Property getx |
|
||||
|
||||
@@ -1,12 +1,54 @@
|
||||
class C(object):
|
||||
class WithDecorator(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
@property
|
||||
def f(self):
|
||||
return self._f
|
||||
def x(self):
|
||||
"""I'm the 'x' property."""
|
||||
return self._x
|
||||
|
||||
@f.setter
|
||||
def f(self, value):
|
||||
self._f = value
|
||||
@x.setter
|
||||
def x(self, value):
|
||||
self._x = value
|
||||
|
||||
@x.deleter
|
||||
def x(self):
|
||||
del self._x
|
||||
|
||||
class WithDecoratorOnlyGetter(object):
|
||||
|
||||
@property
|
||||
def x(self):
|
||||
return 42
|
||||
|
||||
class WithoutDecorator(object):
|
||||
def __init__(self):
|
||||
self._x = None
|
||||
|
||||
def getx(self):
|
||||
return self._x
|
||||
|
||||
def setx(self, value):
|
||||
self._x = value
|
||||
|
||||
def delx(self):
|
||||
del self._x
|
||||
|
||||
x = property(getx, setx, delx, "I'm the 'x' property.")
|
||||
|
||||
class WithoutDecoratorOnlyGetter(object):
|
||||
|
||||
def getx(self):
|
||||
return 42
|
||||
|
||||
x = property(getx)
|
||||
|
||||
class WithoutDecoratorOnlySetter(object):
|
||||
|
||||
def setx(self, value):
|
||||
self._x = value
|
||||
|
||||
x = property(fset=setx) # TODO: Not handled
|
||||
|
||||
class D(object):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user