Select Git revision
test_statistics_device.py
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_statistics_device.py 1.43 KiB
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0
from unittest import mock
from tango import server
from tango.test_context import DeviceTestContext
from test import base
class TestStatisticsDevice(base.TestCase):
def setUp(self):
super(TestStatisticsDevice, self).setUp()
def test_python_bug(self):
"""Python is bugged and super() calls in ctypes fail
This is the same type of issues that prevents combining metaclasses
DeviceMeta and ABCMeta
https://github.com/waveform80/picamera/issues/355
https://bugs.python.org/issue29270
"""
import ctypes as ct
try:
class TestSubclass(ct.c_uint32):
def __repr__(self):
return super().__repr__()
except Exception as e:
self.assertIsInstance(e, TypeError)
@mock.patch.object(server, "get_worker")
def test_instance_statistics(self, m_worker):
"""Test that we can import and create a statistics device
The import of Statistics fails when both ABCMeta and DeviceMeta are
combined. Leave this test to prevent regressions when reattempting our
combined metaclass.
"""
from tangostationcontrol.devices.sdp.statistics import Statistics
with DeviceTestContext(Statistics, process=True) as proxy:
self.assertTrue(proxy.ping() > 0)