Python: Cleanup overrides tests

This commit is contained in:
Rasmus Wriedt Larsen
2020-01-06 10:55:37 +01:00
parent 92e272cc03
commit 9b0b0c338f
2 changed files with 23 additions and 22 deletions

View File

@@ -1,9 +1,9 @@
| test.py:3:5:3:20 | Function Wat.upper | overriding | not overridden |
| test.py:6:1:6:26 | Function outside_func | not overriding | overridden |
| test.py:11:11:11:29 | Function Base.lambda | not overriding | overridden |
| test.py:13:24:13:36 | Function Base.lambda | not overriding | not overridden |
| test.py:17:5:17:21 | Function Base.normal | not overriding | overridden |
| test.py:28:5:28:21 | Function Sub2.foo | overriding | overridden |
| test.py:31:5:31:24 | Function Sub2.tricky | overriding | not overridden |
| test.py:36:5:36:21 | Function Sub2Sub.foo | overriding | not overridden |
| test.py:39:5:39:18 | Function Sub2Sub.baz | overriding | not overridden |
| test.py:3:5:3:20 | Function MyStr.upper | overriding | not overridden |
| test.py:11:1:11:26 | Function outside_func | not overriding | overridden |
| test.py:16:11:16:29 | Function Base.lambda | not overriding | overridden |
| test.py:18:24:18:36 | Function Base.lambda | not overriding | not overridden |
| test.py:22:5:22:21 | Function Base.normal | not overriding | overridden |
| test.py:33:5:33:21 | Function Bar.foo | overriding | overridden |
| test.py:36:5:36:24 | Function Bar.tricky | overriding | not overridden |
| test.py:41:5:41:21 | Function SpecialBar.foo | overriding | not overridden |
| test.py:44:5:44:18 | Function SpecialBar.baz | overriding | not overridden |

View File

@@ -1,8 +1,13 @@
class Wat(str):
class MyStr(str):
def upper(self):
return self.lower()
s = MyStr('asdf')
print(s.upper(), len(s))
def outside_func(self, x):
print(x)
@@ -19,35 +24,31 @@ class Base(object):
tricky = outside_func
class Sub(Base):
class Foo(Base):
normal = False
class Sub2(Base):
class Bar(Base):
def foo(self, y):
return y * 100
def tricky(self, x):
print('nice!', x)
print('tricky!', x)
class Sub2Sub(Sub2):
class SpecialBar(Bar):
def foo(self, z):
return z / 123
def baz(self):
print('python is a bit crazy sometimes')
print('baz')
ws = Wat('asdf')
print(ws.upper(), len(ws))
b = Base()
print(b.foo(1))
print(b.bar(10))
ss = SubSub()
print(ss.foo(1))
ss.baz()
sb = SpecialBar()
print(sb.foo(1))
sb.baz()