Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymodbus/simulator/simcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def build_config(cls, devices: list[SimDevice]) -> SimCore:
if cfg_block:
cls.build_block(cfg_block)

#core.devices[dev.id] = (
core.devices[dev.id] = dev
# block_coil,
# block_direct,
# block_holding,
Expand Down
7 changes: 0 additions & 7 deletions test/datastore/test_simulator_datastore.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ class TestDatastoreSimulator:
# 48 MAX before repeat
]

@staticmethod
@pytest.fixture(name="use_port")
def get_port_in_class(base_ports):
"""Return next port."""
base_ports[__class__.__name__] += 1
return base_ports[__class__.__name__]

@classmethod
def custom_action1(cls, _inx, _cell):
"""Test action."""
Expand Down
6 changes: 0 additions & 6 deletions test/server/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import pytest

from pymodbus.client import AsyncModbusTcpClient
from pymodbus.datastore import ModbusSimulatorContext
from pymodbus.datastore.simulator import Cell, CellType
from pymodbus.server import ModbusSimulatorServer
from pymodbus.server.simulator.main import run_main
Expand Down Expand Up @@ -199,11 +198,6 @@ def copy_default_device(self):
"""Copy default device."""
return copy.deepcopy(self.default_device)

@pytest.fixture(name="simulator")
def create_simulator(self, device):
"""Create simulator context."""
return ModbusSimulatorContext(device, self.custom_actions)

@pytest.fixture(name="server")
def copy_default_server(self, use_port):
"""Create simulator context."""
Expand Down
14 changes: 13 additions & 1 deletion test/simulator/test_simcore.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Test SimCore."""

import pytest

from pymodbus.simulator import SimCore
from pymodbus.simulator import SimCore, SimData, SimDevice


class TestSimCore:
Expand All @@ -10,3 +11,14 @@ class TestSimCore:
def test_instanciate(self):
"""Test that simdata can be objects."""
SimCore()

def test_build_block(self):
"""Test that simdata can be objects."""
SimCore.build_block(None)

def test_build_config(self):
"""Test that simdata can be objects."""
device = SimDevice(17, block_shared=[SimData(0)])
SimCore.build_config([device])
with pytest.raises(TypeError):
SimCore.build_config([device, device])
1 change: 1 addition & 0 deletions test/simulator/test_simdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def test_simdata_datatype(self, datatype):
(1.0, SimDataType.FLOAT32),
(11, SimDataType.REGISTERS),
(True, SimDataType.BITS),
(17, SimDataType.DEFAULT),
])
def test_simdata_value_ok(self, value, value_type):
"""Test simdata value."""
Expand Down