File: test73.py

package info (click to toggle)
pychecker 0.8.19-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,484 kB
  • ctags: 2,114
  • sloc: python: 9,968; sh: 98; makefile: 13
file content (37 lines) | stat: -rw-r--r-- 1,086 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'test abstract classes'

__pychecker__ = 'no-classdoc'

class Abstract:
    def f(self): raise NotImplementedError, "override in subclass"
    def g(self): raise NotImplementedError
class ConcreteBad(Abstract):
    def g(self): pass
class ConcreteGood(ConcreteBad):
    def f(self): pass
a = Abstract()                          # error
cb = ConcreteBad()                      # error
cg = ConcreteGood()                     # ok, f defined

class ConcreteInst:
    def f(self): raise SystemError("not yet ready for prime time")
ch = ConcreteInst()                     # ok, raises SystemError

class AbstractInst:
    def f(self): raise NotImplementedError("not yet ready for prime time")
ch = AbstractInst()

cb.g()
def f():
    class MoreBad(Abstract):
        def g(): pass
    _ = MoreBad()                       # FIXME, error not caught

import import73
class ImplAbstract(import73.AbstractLib):
    def __init__(self):
        import73.AbstractLib.__init__(self)

def lib_example():
    _ = import73.AbstractLib()          # error
    unused = ImplAbstract()             # error