# Path: pyrep/errors.py
# class PyRepError(Exception):
#     pass
# 
# Path: tests/core.py
# class TestCore(unittest.TestCase):
# 
#     def setUp(self):
#         self.pyrep = PyRep()
#         self.pyrep.launch(path.join(ASSET_DIR, 'test_scene.ttt'), headless=True)
#         self.pyrep.step()
#         self.pyrep.start()
# 
#     def tearDown(self):
#         self.pyrep.stop()
#         self.pyrep.step_ui()
#         self.pyrep.shutdown()
# 
# Path: pyrep/misc/distance.py
# class Distance(object):
#     """Allows registering distance objects which are measurable entity-pairs."""
# 
#     def __init__(self, name_or_handle: Union[str, int]):
#         raise PyRepError(
#             'Currently there is an error in CoppeliaSim with distance objects. '
#             'As soon as CoppeliaSim resolves this issue, this error will be '
#             'removed.')
#         self._handle: int
#         if isinstance(name_or_handle, int):
#             self._handle = name_or_handle
#         else:
#             self._handle = sim.simGetDistanceHandle(name_or_handle)
#         # The entity needs to be set as explicit handling for reads to work.
#         if not sim.simGetExplicitHandling(self._handle):
#             sim.simSetExplicitHandling(self._handle, 1)
# 
#     def __eq__(self, other: object):
#         if not isinstance(other, Distance):
#             raise NotImplementedError
#         return self.get_handle() == other.get_handle()
# 
#     def get_handle(self) -> int:
#         """Gets the internal handle of this object.
# 
#         :return: The internal handle.
#         """
#         return self._handle
# 
#     def read(self) -> Union[float, None]:
#         """Reads the distance of a registered distance object.
# 
#         :raises: PyRepError if no objects could be measured.
# 
#         :return: The smallest distance between the 2 entities or None if no
#             measurement could be made.
#         """
#         num_measurements = sim.simHandleDistance(self._handle)
#         if num_measurements == 0:
#             raise PyRepError(
#                 'Could not make a measurement. Are both entities associated '
#                 'with the distance object marked as measurable?')
#         return (None if num_measurements == 0
#                 else sim.simReadDistance(self._handle))
# 
# Path: pyrep/misc/signals.py
# class IntegerSignal(Signal):
#     """An integer-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetIntegerSignal(self._name, value)
# 
#     def get(self) -> int:
#         ret, value = sim.simGetIntegerSignal(self._name)
#         self._check_signal(ret, 'int')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearIntegerSignal(self._name)
# 
# class FloatSignal(Signal):
#     """An float-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetFloatSignal(self._name, value)
# 
#     def get(self) -> float:
#         ret, value = sim.simGetFloatSignal(self._name)
#         self._check_signal(ret, 'float')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearFloatSignal(self._name)
# 
# Path: pyrep/misc/signals.py
# class DoubleSignal(Signal):
#     """An double-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetDoubleSignal(self._name, value)
# 
#     def get(self) -> float:
#         ret, value = sim.simGetDoubleSignal(self._name)
#         self._check_signal(ret, 'double')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearDoubleSignal(self._name)
# 
# class StringSignal(Signal):
#     """An string-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetStringSignal(self._name, value)
# 
#     def get(self) -> str:
#         ret, value = sim.simGetStringSignal(self._name)
#         self._check_signal(ret, 'string')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearStringSignal(self._name)


import unittest
from pyrep.errors import PyRepError
from tests.core import TestCore
from pyrep.misc.distance import Distance
from pyrep.misc.signals import IntegerSignal, FloatSignal
from pyrep.misc.signals import DoubleSignal, StringSignal


# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
    pass

    # def test_get_distance(self):
        # Distance('dist_cubes')

    # def test_read_distance(self):
        # d = Distance('dist_cubes')
        # dist = d.read()
        # self.assertAlmostEqual(dist, 0.1, places=3)

    # def test_read_distance_not_measurable(self):
        # d = Distance('dist_cubes_fail')
        # with self.assertRaises(PyRepError):
        #     d.read()


class TestSignal(TestCore):

    SIGNALS = [
        (IntegerSignal, 99),
        (FloatSignal, 55.3),

# Path: pyrep/errors.py
# class PyRepError(Exception):
#     pass
# 
# Path: tests/core.py
# class TestCore(unittest.TestCase):
# 
#     def setUp(self):
#         self.pyrep = PyRep()
#         self.pyrep.launch(path.join(ASSET_DIR, 'test_scene.ttt'), headless=True)
#         self.pyrep.step()
#         self.pyrep.start()
# 
#     def tearDown(self):
#         self.pyrep.stop()
#         self.pyrep.step_ui()
#         self.pyrep.shutdown()
# 
# Path: pyrep/misc/distance.py
# class Distance(object):
#     """Allows registering distance objects which are measurable entity-pairs."""
# 
#     def __init__(self, name_or_handle: Union[str, int]):
#         raise PyRepError(
#             'Currently there is an error in CoppeliaSim with distance objects. '
#             'As soon as CoppeliaSim resolves this issue, this error will be '
#             'removed.')
#         self._handle: int
#         if isinstance(name_or_handle, int):
#             self._handle = name_or_handle
#         else:
#             self._handle = sim.simGetDistanceHandle(name_or_handle)
#         # The entity needs to be set as explicit handling for reads to work.
#         if not sim.simGetExplicitHandling(self._handle):
#             sim.simSetExplicitHandling(self._handle, 1)
# 
#     def __eq__(self, other: object):
#         if not isinstance(other, Distance):
#             raise NotImplementedError
#         return self.get_handle() == other.get_handle()
# 
#     def get_handle(self) -> int:
#         """Gets the internal handle of this object.
# 
#         :return: The internal handle.
#         """
#         return self._handle
# 
#     def read(self) -> Union[float, None]:
#         """Reads the distance of a registered distance object.
# 
#         :raises: PyRepError if no objects could be measured.
# 
#         :return: The smallest distance between the 2 entities or None if no
#             measurement could be made.
#         """
#         num_measurements = sim.simHandleDistance(self._handle)
#         if num_measurements == 0:
#             raise PyRepError(
#                 'Could not make a measurement. Are both entities associated '
#                 'with the distance object marked as measurable?')
#         return (None if num_measurements == 0
#                 else sim.simReadDistance(self._handle))
# 
# Path: pyrep/misc/signals.py
# class IntegerSignal(Signal):
#     """An integer-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetIntegerSignal(self._name, value)
# 
#     def get(self) -> int:
#         ret, value = sim.simGetIntegerSignal(self._name)
#         self._check_signal(ret, 'int')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearIntegerSignal(self._name)
# 
# class FloatSignal(Signal):
#     """An float-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetFloatSignal(self._name, value)
# 
#     def get(self) -> float:
#         ret, value = sim.simGetFloatSignal(self._name)
#         self._check_signal(ret, 'float')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearFloatSignal(self._name)
# 
# Path: pyrep/misc/signals.py
# class DoubleSignal(Signal):
#     """An double-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetDoubleSignal(self._name, value)
# 
#     def get(self) -> float:
#         ret, value = sim.simGetDoubleSignal(self._name)
#         self._check_signal(ret, 'double')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearDoubleSignal(self._name)
# 
# class StringSignal(Signal):
#     """An string-type signal."""
# 
#     def set(self, value) -> None:
#         sim.simSetStringSignal(self._name, value)
# 
#     def get(self) -> str:
#         ret, value = sim.simGetStringSignal(self._name)
#         self._check_signal(ret, 'string')
#         return value
# 
#     def clear(self) -> int:
#         return sim.simClearStringSignal(self._name)


# Path: tests/test_misc.py
import unittest
from pyrep.errors import PyRepError
from tests.core import TestCore
from pyrep.misc.distance import Distance
from pyrep.misc.signals import IntegerSignal, FloatSignal
from pyrep.misc.signals import DoubleSignal, StringSignal



# TODO: These tests will be re-enabled once bug has been fixed in CoppeliaSim.
class TestMisc(TestCore):
    pass

    # def test_get_distance(self):
        # Distance('dist_cubes')

    # def test_read_distance(self):
        # d = Distance('dist_cubes')
        # dist = d.read()
        # self.assertAlmostEqual(dist, 0.1, places=3)

    # def test_read_distance_not_measurable(self):
        # d = Distance('dist_cubes_fail')
        # with self.assertRaises(PyRepError):
        #     d.read()


class TestSignal(TestCore):

    SIGNALS = [
        (IntegerSignal, 99),
        (FloatSignal, 55.3),

        (DoubleSignal, 22.2),