Skip to content

Commit

Permalink
Fix Complex tests for changes in Python 3.12
Browse files Browse the repository at this point in the history
These tests are borderline useless anyway, we should think about removing them.
  • Loading branch information
ffl096 committed Jul 6, 2024
1 parent 7a383b9 commit 38400db
Showing 1 changed file with 6 additions and 48 deletions.
54 changes: 6 additions & 48 deletions test/classes/test_complex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Test Complex class."""

from abc import ABCMeta

import pytest

from toponetx.classes.complex import Complex
Expand All @@ -12,14 +10,8 @@ class TestComplex:

def test_complex_is_abstract(self):
"""Test if the Complex abstract class is abstract."""
with pytest.raises(TypeError) as exp_exception:
Complex()

assert "Can't instantiate abstract class Complex with abstract methods" in str(
exp_exception.value
)

assert isinstance(Complex, ABCMeta)
with pytest.raises(TypeError):
_ = Complex()

def test_complex_has_abstract_methods(self):
"""Test if the Complex abstract class has all the abstract methods."""
Expand Down Expand Up @@ -48,36 +40,7 @@ def test_complex_inheritance_check(self):
"""Test that the abstract class is forcing implementation in all children classes."""

class ExampleClass(Complex):
"""Create an example class to test Complex Class.
Parameters
----------
name : str
Name of the Complex.
*args
Positional arguments to be passed to the constructor.
**kwargs
Keyword arguments to be passed to the constructor.
"""

def __init__(self, name: str = "", *args, **kwargs) -> None:
"""Initialize the example class.
Parameters
----------
name : str
Name of the Complex.
*args
Positional arguments to be passed to the constructor.
**kwargs
Keyword arguments to be passed to the constructor.
Returns
-------
ExampleClass
The example class is initialized and returned.
"""
super().__init__(name, *args, **kwargs)
"""Create an example class to test Complex Class."""

def clone(self):
"""Test expected behavior from ExampleClass.
Expand All @@ -87,12 +50,7 @@ def clone(self):
NotImplementedError
Currently NotImplementedError is raised.
"""
return NotImplementedError

with pytest.raises(TypeError) as exp_exception:
ExampleClass()
return NotImplementedError()

assert (
"Can't instantiate abstract class ExampleClass with abstract methods"
in str(exp_exception.value)
)
with pytest.raises(TypeError):
_ = ExampleClass()

0 comments on commit 38400db

Please sign in to comment.