File: test_class_misc.py

package info (click to toggle)
sip6 6.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,608 kB
  • sloc: ansic: 192,441; python: 20,668; makefile: 25; cpp: 8
file content (42 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# SPDX-License-Identifier: BSD-2-Clause

# Copyright (c) 2025 Phil Thompson <phil@riverbankcomputing.com>


import pytest


def test_simplewrapper_instantiation(module):
    with pytest.raises(TypeError):
        module.simplewrapper()

def test_wrapper_instantiation(module):
    with pytest.raises(TypeError):
        module.wrapper()

def test_plain_class_mro(module):
    assert len(module.Klass.__mro__) == 4

def test_plain_class_isinstance(module):
    assert isinstance(module.Klass(), module.Klass)

def test_nested_class_isinstance(module):
    assert isinstance(module.Klass.Nested(), module.Klass.Nested)

def test_py_subclass(module):
    class SubK(module.Klass):
        pass

    assert isinstance(SubK(), module.Klass)

def test_simple_plain_class_mro(module):
    assert len(module.SimpleKlass.__mro__) == 3

def test_simple_plain_class_isinstance(module):
    assert isinstance(module.SimpleKlass(), module.SimpleKlass)

def test_simple_py_subclass(module):
    class SimpleSubK(module.SimpleKlass):
        pass

    assert isinstance(SimpleSubK(), module.SimpleKlass)