aboutsummaryrefslogtreecommitdiff
path: root/tests/test_factory_constructors.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_factory_constructors.py')
-rw-r--r--tests/test_factory_constructors.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/tests/test_factory_constructors.py b/tests/test_factory_constructors.py
index ffcce6fd..04df8026 100644
--- a/tests/test_factory_constructors.py
+++ b/tests/test_factory_constructors.py
@@ -1,12 +1,10 @@
-# -*- coding: utf-8 -*-
-import pytest
import re
-import env # noqa: F401
+import pytest
+from pybind11_tests import ConstructorStats
from pybind11_tests import factory_constructors as m
from pybind11_tests.factory_constructors import tag
-from pybind11_tests import ConstructorStats
def test_init_factory_basic():
@@ -82,7 +80,7 @@ def test_init_factory_signature(msg):
4. m.factory_constructors.TestFactory1(arg0: handle, arg1: int, arg2: handle)
Invoked with: 'invalid', 'constructor', 'arguments'
- """ # noqa: E501 line too long
+ """
)
assert (
@@ -98,7 +96,7 @@ def test_init_factory_signature(msg):
3. __init__(self: m.factory_constructors.TestFactory1, arg0: m.factory_constructors.tag.pointer_tag) -> None
4. __init__(self: m.factory_constructors.TestFactory1, arg0: handle, arg1: int, arg2: handle) -> None
- """ # noqa: E501 line too long
+ """
)
@@ -465,12 +463,10 @@ def test_reallocation_g(capture, msg):
)
-@pytest.mark.skipif("env.PY2")
def test_invalid_self():
- """Tests invocation of the pybind-registered base class with an invalid `self` argument. You
- can only actually do this on Python 3: Python 2 raises an exception itself if you try."""
+ """Tests invocation of the pybind-registered base class with an invalid `self` argument."""
- class NotPybindDerived(object):
+ class NotPybindDerived:
pass
# Attempts to initialize with an invalid type passed as `self`:
@@ -486,7 +482,9 @@ def test_invalid_self():
# Same as above, but for a class with an alias:
class BrokenTF6(m.TestFactory6):
def __init__(self, bad):
- if bad == 1:
+ if bad == 0:
+ m.TestFactory6.__init__()
+ elif bad == 1:
a = m.TestFactory2(tag.pointer, 1)
m.TestFactory6.__init__(a, tag.base, 1)
elif bad == 2:
@@ -506,13 +504,13 @@ def test_invalid_self():
BrokenTF1(arg)
assert (
str(excinfo.value)
- == "__init__(self, ...) called with invalid `self` argument"
+ == "__init__(self, ...) called with invalid or missing `self` argument"
)
- for arg in (1, 2, 3, 4):
+ for arg in (0, 1, 2, 3, 4):
with pytest.raises(TypeError) as excinfo:
BrokenTF6(arg)
assert (
str(excinfo.value)
- == "__init__(self, ...) called with invalid `self` argument"
+ == "__init__(self, ...) called with invalid or missing `self` argument"
)