Llama-3.1-8B-DALv0.1
/
venv
/lib
/python3.12
/site-packages
/sympy
/physics
/biomechanics
/tests
/test_mixin.py
"""Tests for the ``sympy.physics.biomechanics._mixin.py`` module.""" | |
import pytest | |
from sympy.physics.biomechanics._mixin import _NamedMixin | |
class TestNamedMixin: | |
def test_subclass(): | |
class Subclass(_NamedMixin): | |
def __init__(self, name): | |
self.name = name | |
instance = Subclass('name') | |
assert instance.name == 'name' | |
def _named_mixin_fixture(self): | |
class Subclass(_NamedMixin): | |
def __init__(self, name): | |
self.name = name | |
self.Subclass = Subclass | |
def test_valid_name_argument(self, name): | |
instance = self.Subclass(name) | |
assert instance.name == name | |
def test_invalid_name_argument_not_str(self, invalid_name): | |
with pytest.raises(TypeError): | |
_ = self.Subclass(invalid_name) | |
def test_invalid_name_argument_zero_length_str(self): | |
with pytest.raises(ValueError): | |
_ = self.Subclass('') | |
def test_name_attribute_is_immutable(self): | |
instance = self.Subclass('name') | |
with pytest.raises(AttributeError): | |
instance.name = 'new_name' | |