tests: cleanup and ci hardening (#2397)

* tests: refactor and cleanup

* refactor: more consistent

* tests: vendor six

* tests: more xfails, nicer system

* tests: simplify to info

* tests: suggestions from @YannickJadoul and @bstaletic

* tests: restore some pypy tests that now pass

* tests: rename info to env

* tests: strict False/True

* tests: drop explicit strict=True again

* tests: reduce minimum PyTest to 3.1
This commit is contained in:
Henry Schreiner
2020-08-16 16:02:12 -04:00
committed by GitHub
parent 3618bea2aa
commit 4d9024ec71
26 changed files with 158 additions and 171 deletions

View File

@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
import pytest
import env # noqa: F401
from pybind11_tests import builtin_casters as m
from pybind11_tests import UserType, IncType
@@ -117,10 +119,7 @@ def test_bytes_to_string():
# Issue #816
def to_bytes(s):
if pytest.PY2:
b = s
else:
b = s.encode("utf8")
b = s if env.PY2 else s.encode("utf8")
assert isinstance(b, bytes)
return b
@@ -197,7 +196,7 @@ def test_integer_casting():
assert m.i64_str(-1) == "-1"
assert m.i32_str(2000000000) == "2000000000"
assert m.u32_str(2000000000) == "2000000000"
if pytest.PY2:
if env.PY2:
assert m.i32_str(long(-1)) == "-1" # noqa: F821 undefined name 'long'
assert m.i64_str(long(-1)) == "-1" # noqa: F821 undefined name 'long'
assert m.i64_str(long(-999999999999)) == "-999999999999" # noqa: F821 undefined name
@@ -219,7 +218,7 @@ def test_integer_casting():
m.i32_str(3000000000)
assert "incompatible function arguments" in str(excinfo.value)
if pytest.PY2:
if env.PY2:
with pytest.raises(TypeError) as excinfo:
m.u32_str(long(-1)) # noqa: F821 undefined name 'long'
assert "incompatible function arguments" in str(excinfo.value)
@@ -360,9 +359,9 @@ def test_bool_caster():
assert convert(A(False)) is False
@pytest.requires_numpy
def test_numpy_bool():
import numpy as np
np = pytest.importorskip("numpy")
convert, noconvert = m.bool_passthrough, m.bool_passthrough_noconvert
def cant_convert(v):