[pypy-commit] pypy anntype: Use an annotator fixture in test_model.py

rlamy noreply at buildbot.pypy.org
Wed Nov 18 18:28:54 EST 2015


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: anntype
Changeset: r80768:a9885feba211
Date: 2015-11-18 23:30 +0000
http://bitbucket.org/pypy/pypy/changeset/a9885feba211/

Log:	Use an annotator fixture in test_model.py

diff --git a/rpython/annotator/test/test_model.py b/rpython/annotator/test/test_model.py
--- a/rpython/annotator/test/test_model.py
+++ b/rpython/annotator/test/test_model.py
@@ -1,9 +1,14 @@
-import py
+import pytest
 
 from rpython.annotator.model import *
 from rpython.annotator.listdef import ListDef
 from rpython.translator.translator import TranslationContext
 
+ at pytest.fixture()
+def annotator():
+    t = TranslationContext()
+    return t.buildannotator()
+
 
 listdef1 = ListDef(None, SomeTuple([SomeInteger(nonneg=True), SomeString()]))
 listdef2 = ListDef(None, SomeTuple([SomeInteger(nonneg=False), SomeString()]))
@@ -100,19 +105,21 @@
 class AAA(object):
     pass
 
-def test_blocked_inference1():
+def test_blocked_inference1(annotator):
     def blocked_inference():
         return AAA().m()
 
-    py.test.raises(AnnotatorError, compile_function, blocked_inference)
+    with pytest.raises(AnnotatorError):
+        annotator.build_types(blocked_inference, [])
 
-def test_blocked_inference2():
+def test_blocked_inference2(annotator):
     def blocked_inference():
         a = AAA()
         b = a.x
         return b
 
-    py.test.raises(AnnotatorError, compile_function, blocked_inference)
+    with pytest.raises(AnnotatorError):
+        annotator.build_types(blocked_inference, [])
 
 
 def test_not_const():


More information about the pypy-commit mailing list