File: test_exceptions.py

package info (click to toggle)
pymodbus 3.8.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,720 kB
  • sloc: python: 14,867; makefile: 27; sh: 17
file content (28 lines) | stat: -rw-r--r-- 772 bytes parent folder | download | duplicates (2)
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
"""Test exceptions."""
import pytest

from pymodbus.exceptions import (
    ConnectionException,
    ModbusException,
    ModbusIOException,
    NotImplementedException,
    ParameterException,
)


class TestExceptions:  # pylint: disable=too-few-public-methods
    """Unittest for the pymodbus.exceptions module."""

    exceptions = [
        ModbusException("bad base"),
        ModbusIOException("bad register"),
        ParameterException("bad parameter"),
        NotImplementedException("bad function"),
        ConnectionException("bad connection"),
    ]

    def test_exceptions(self):
        """Test all module exceptions."""
        for exc in self.exceptions:
            with pytest.raises(ModbusException, match="Modbus Error:"):
                raise exc