1 """Test zipfile compat.
12 # dont fail on new python by default
13 _VERS
= [(3, 6), (3, 7), (3, 8)]
15 _UNSUPPORTED
= sys
.version_info
[:2] not in _VERS
39 def load_cls_names(maincls
):
40 assert inspect
.isclass(maincls
)
42 for cls
in inspect
.getmro(maincls
):
43 for name
, val
in inspect
.getmembers(cls
):
50 res
= str(sig
).replace(", /", "")
52 res
= res
.split(", *", 1)[0] + ")"
56 def compare(rmaincls
, zmaincls
):
57 znames
= load_cls_names(zmaincls
)
58 rnames
= load_cls_names(rmaincls
)
59 for name
, zval
in znames
.items():
60 if not inspect
.isroutine(zval
) or name
[0] == "_" or name
in _ignore
:
62 assert name
in rnames
, "member not found: \"%s\"" % name
65 zsig
= inspect
.signature(zval
)
66 rsig
= inspect
.signature(rval
)
68 zsigstr
= cleansig(zsig
)
69 rsigstr
= cleansig(rsig
)
70 assert zsigstr
== rsigstr
, "sig differs: %s.%s%s != %s.%s%s" % (
71 rmaincls
.__name
__, name
, rsigstr
,
72 zmaincls
.__name
__, name
, zsigstr
)
75 @pytest.mark
.skipif(_UNSUPPORTED
, reason
="Unsupported for sig checks")
76 def test_cmp_zipfile():
77 compare(rarfile
.RarFile
, zipfile
.ZipFile
)
80 @pytest.mark
.skipif(_UNSUPPORTED
, reason
="Unsupported for sig checks")
81 def test_cmp_zipextfile():
82 compare(rarfile
.RarExtFile
, zipfile
.ZipExtFile
)
85 @pytest.mark
.skipif(_UNSUPPORTED
, reason
="Unsupported for sig checks")
86 def test_cmp_zipinfo():
87 compare(rarfile
.RarInfo
, zipfile
.ZipInfo
)