pypy3 does not have the AttributeError/TypeError difference

This commit is contained in:
Carlos Martín Nieto
2014-09-06 19:04:39 +02:00
parent ae00fe4522
commit 81104d4df2
2 changed files with 12 additions and 7 deletions

View File

@@ -35,12 +35,15 @@ import sys
from pygit2 import GIT_OBJ_COMMIT, Signature, Oid from pygit2 import GIT_OBJ_COMMIT, Signature, Oid
from . import utils from . import utils
# pypy raises TypeError on writing to read-only, so we need to check # pypy (in python2 mode) raises TypeError on writing to read-only, so
# and change the test accordingly # we need to check and change the test accordingly
try: try:
import __pypy__ import __pypy__
import __pypy__, sys
pypy2 = sys.version_info[0] < 3
except ImportError: except ImportError:
__pypy__ = None __pypy__ = None
pypy2 = False
COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10' COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10'
@@ -149,7 +152,7 @@ class CommitTest(utils.BareRepoTestCase):
commit = self.repo[COMMIT_SHA] commit = self.repo[COMMIT_SHA]
error_type = AttributeError if not __pypy__ else TypeError error_type = AttributeError if not pypy2 else TypeError
self.assertRaises(error_type, setattr, commit, 'message', message) self.assertRaises(error_type, setattr, commit, 'message', message)
self.assertRaises(error_type, setattr, commit, 'committer', committer) self.assertRaises(error_type, setattr, commit, 'committer', committer)
self.assertRaises(error_type, setattr, commit, 'author', author) self.assertRaises(error_type, setattr, commit, 'author', author)

View File

@@ -34,12 +34,14 @@ import unittest
import pygit2 import pygit2
from . import utils from . import utils
# pypy raises TypeError on writing to read-only, so we need to check # pypy (in python2 mode) raises TypeError on writing to read-only, so
# and change the test accordingly # we need to check and change the test accordingly
try: try:
import __pypy__ import __pypy__, sys
pypy2 = sys.version_info[0] < 3
except ImportError: except ImportError:
__pypy__ = None __pypy__ = None
pypy2 = False
TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369' TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369'
@@ -90,7 +92,7 @@ class TagTest(utils.BareRepoTestCase):
tagger = ('John Doe', 'jdoe@example.com', 12347) tagger = ('John Doe', 'jdoe@example.com', 12347)
tag = self.repo[TAG_SHA] tag = self.repo[TAG_SHA]
error_type = AttributeError if not __pypy__ else TypeError error_type = AttributeError if not pypy2 else TypeError
self.assertRaises(error_type, setattr, tag, 'name', name) self.assertRaises(error_type, setattr, tag, 'name', name)
self.assertRaises(error_type, setattr, tag, 'target', target) self.assertRaises(error_type, setattr, tag, 'target', target)
self.assertRaises(error_type, setattr, tag, 'tagger', tagger) self.assertRaises(error_type, setattr, tag, 'tagger', tagger)