simplify

Changeset

122:30b827a8c13f
2006-10-30 paulb raw files shortlog changelog graph Added attribute test. Enhanced the exceptions test to use a function.
tests/attr.py (file) tests/tryexcept.py (file)
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tests/attr.py	Mon Oct 30 23:33:22 2006 +0100
     1.3 @@ -0,0 +1,12 @@
     1.4 +class A:
     1.5 +    pass
     1.6 +class B:
     1.7 +    pass
     1.8 +
     1.9 +x = 1
    1.10 +if x:
    1.11 +    a = A()
    1.12 +    a.x = 2
    1.13 +else:
    1.14 +    a = B()
    1.15 +a.x
     2.1 --- a/tests/tryexcept.py	Mon Oct 30 23:32:38 2006 +0100
     2.2 +++ b/tests/tryexcept.py	Mon Oct 30 23:33:22 2006 +0100
     2.3 @@ -4,13 +4,19 @@
     2.4      pass
     2.5  class C:
     2.6      pass
     2.7 -x = 1
     2.8 -try:
     2.9 -    if x:
    2.10 -        raise A
    2.11 +
    2.12 +def f():
    2.13 +    x = 1
    2.14 +    try:
    2.15 +        if x:
    2.16 +            raise A
    2.17 +        else:
    2.18 +            raise B
    2.19 +    except A, e:
    2.20 +        a = e
    2.21 +    except (B, C), f:
    2.22 +        a = f
    2.23      else:
    2.24 -        raise B
    2.25 -except A, e:
    2.26 -    a = e
    2.27 -except (B, C), f:
    2.28 -    a = f
    2.29 +        a = x
    2.30 +
    2.31 +f()