Skip to content

Commit 52ddd79

Browse files
committed
Python: Add 2/3 specific query tests.
1 parent 0558b58 commit 52ddd79

File tree

152 files changed

+919
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+919
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| equals_hash.py:8:5:8:28 | Function __eq__ | Class $@ implements __eq__ but does not define __hash__. | equals_hash.py:3:1:3:17 | class Eq | Eq |
2+
| equals_hash.py:24:5:24:23 | Function __hash__ | Class $@ implements __hash__ but does not define __eq__ or __cmp__. | equals_hash.py:19:1:19:19 | class Hash | Hash |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Classes/EqualsOrHash.ql
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| equals_hash.py:8:5:8:28 | Function __eq__ | Class $@ implements __eq__ but does not implement __ne__. | equals_hash.py:3:1:3:17 | class Eq | Eq |
2+
| equals_hash.py:16:5:16:28 | Function __ne__ | Class $@ implements __ne__ but does not implement __eq__. | equals_hash.py:11:1:11:17 | class Ne | Ne |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Classes/EqualsOrNotEquals.ql
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#Equals and hash
2+
3+
class Eq(object):
4+
5+
def __init__(self, data):
6+
self.data = data
7+
8+
def __eq__(self, other):
9+
return self.data == other.data
10+
11+
class Ne(object):
12+
13+
def __init__(self, data):
14+
self.data = data
15+
16+
def __ne__(self, other):
17+
return self.data != other.data
18+
19+
class Hash(object):
20+
21+
def __init__(self, data):
22+
self.data = data
23+
24+
def __hash__(self):
25+
return hash(self.data)
26+
27+
class Unhashable1(object):
28+
29+
__hash__ = None
30+
31+
32+
class EqOK1(Unhashable1):
33+
34+
def __eq__(self, other):
35+
return False
36+
37+
def __ne__(self, other):
38+
return True
39+
40+
class Unhashable2(object):
41+
42+
#Not the idiomatic way of doing it, but not uncommon either
43+
def __hash__(self):
44+
raise TypeError("unhashable object")
45+
46+
47+
class EqOK2(Unhashable2):
48+
49+
def __eq__(self, other):
50+
return False
51+
52+
def __ne__(self, other):
53+
return True
54+
55+
class ReflectiveNotEquals(object):
56+
57+
def __ne__(self, other):
58+
return not self == other
59+
60+
class EqOK3(ReflectiveNotEquals, Unhashable1):
61+
62+
def __eq__(self, other):
63+
return self.data == other.data
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| inconsistent_mro.py:9:1:9:14 | class Z | Construction of class Z can fail due to invalid method resolution order(MRO) for bases $@ and $@. | inconsistent_mro.py:3:1:3:16 | class X | X | inconsistent_mro.py:6:1:6:11 | class Y | Y |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Classes/InconsistentMRO.ql
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#Inconsistent MRO
2+
3+
class X(object):
4+
pass
5+
6+
class Y(X):
7+
pass
8+
9+
class Z(X, Y):
10+
pass
11+
12+
class O:
13+
pass
14+
15+
#This is OK in Python 2
16+
class N(object, O):
17+
pass
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| property_old_style.py:8:6:8:13 | Property piosc | Property piosc will not work properly, as class OldStyle is an old-style class. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Classes/PropertyInOldStyleClass.ql

0 commit comments

Comments
 (0)