Skip to content

Commit 3a4bafc

Browse files
committed
pypy3 does not have the AttributeError/TypeError difference
1 parent ae00fe4 commit 3a4bafc

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

test/test_commit.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@
3535
from pygit2 import GIT_OBJ_COMMIT, Signature, Oid
3636
from . import utils
3737

38-
# pypy raises TypeError on writing to read-only, so we need to check
39-
# and change the test accordingly
38+
# pypy (in python2 mode) raises TypeError on writing to read-only, so
39+
# we need to check and change the test accordingly
4040
try:
4141
import __pypy__
42+
import __pypy__, sys
43+
pypy2 = sys.version_info[0] < 3
4244
except ImportError:
4345
__pypy__ = None
46+
pypy2 = False
4447

4548
COMMIT_SHA = '5fe808e8953c12735680c257f56600cb0de44b10'
4649

@@ -149,7 +152,7 @@ def test_modify_commit(self):
149152

150153
commit = self.repo[COMMIT_SHA]
151154

152-
error_type = AttributeError if not __pypy__ else TypeError
155+
error_type = AttributeError if not pypy2 else TypeError
153156
self.assertRaises(error_type, setattr, commit, 'message', message)
154157
self.assertRaises(error_type, setattr, commit, 'committer', committer)
155158
self.assertRaises(error_type, setattr, commit, 'author', author)

test/test_tag.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
import pygit2
3535
from . import utils
3636

37-
# pypy raises TypeError on writing to read-only, so we need to check
38-
# and change the test accordingly
37+
# pypy (in python2 mode) raises TypeError on writing to read-only, so
38+
# we need to check and change the test accordingly
3939
try:
40-
import __pypy__
40+
import __pypy__, sys
41+
pypy2 = sys.version_info[0] < 3:
42+
pypy2 = True
4143
except ImportError:
4244
__pypy__ = None
45+
pypy2 = False
4346

4447
TAG_SHA = '3d2962987c695a29f1f80b6c3aa4ec046ef44369'
4548

@@ -90,7 +93,7 @@ def test_modify_tag(self):
9093
tagger = ('John Doe', '[email protected]', 12347)
9194

9295
tag = self.repo[TAG_SHA]
93-
error_type = AttributeError if not __pypy__ else TypeError
96+
error_type = AttributeError if not pypy2 else TypeError
9497
self.assertRaises(error_type, setattr, tag, 'name', name)
9598
self.assertRaises(error_type, setattr, tag, 'target', target)
9699
self.assertRaises(error_type, setattr, tag, 'tagger', tagger)

0 commit comments

Comments
 (0)