| 1 |
"""In which we test that various pieces of py2-only syntax are supported.""" |
| 2 |
from __future__ import with_statement |
| 3 |
import py |
| 4 |
|
| 5 |
from rpython.flowspace.flowcontext import FlowingError |
| 6 |
from .test_objspace import Base |
| 7 |
|
| 8 |
|
| 9 |
class TestFlowObjSpacePy2(Base): |
| 10 |
|
| 11 |
|
| 12 |
def raise2(msg): |
| 13 |
raise IndexError, msg |
| 14 |
|
| 15 |
def test_raise2(self): |
| 16 |
x = self.codetest(self.raise2) |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
def raisez(z, tb): |
| 21 |
raise z.__class__,z, tb |
| 22 |
|
| 23 |
def test_raisez(self): |
| 24 |
x = self.codetest(self.raisez) |
| 25 |
|
| 26 |
|
| 27 |
def print_(i): |
| 28 |
print i |
| 29 |
|
| 30 |
def test_print(self): |
| 31 |
x = self.codetest(self.print_) |
| 32 |
|
| 33 |
def test_bad_print(self): |
| 34 |
def f(x): |
| 35 |
print >> x, "Hello" |
| 36 |
with py.test.raises(FlowingError): |
| 37 |
self.codetest(f) |