~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to py/magic/testing/test_invoke.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import __builtin__ as bltin
 
2
import py
 
3
import inspect
 
4
 
 
5
def check_assertion():
 
6
    excinfo = py.test.raises(AssertionError, "assert 1 == 2")
 
7
    assert excinfo.exconly(tryshort=True) == "assert 1 == 2"
 
8
 
 
9
def test_invoke_assertion():
 
10
    py.magic.invoke(assertion=True)
 
11
    try:
 
12
        check_assertion()
 
13
    finally:
 
14
        py.magic.revoke(assertion=True)
 
15
 
 
16
def test_invoke_compile():
 
17
    py.magic.invoke(compile=True)
 
18
    try:
 
19
        co = compile("""if 1: 
 
20
                    def f(): 
 
21
                        return 1
 
22
                    \n""", '', 'exec')
 
23
        d = {}
 
24
        exec co in d
 
25
        assert py.code.Source(d['f']) 
 
26
    finally:
 
27
        py.magic.revoke(compile=True)
 
28
 
 
29