コード例 #1
0
 def setUp(self):
     self.laser = dummies.TestLightSource()
     self.filterwheel = dummies.TestFilterWheel(positions=6)
     self.device = dummies.TestController({
         "laser": self.laser,
         "filterwheel": self.filterwheel
     })
コード例 #2
0
ファイル: test_devices.py プロジェクト: beniroquai/microscope
    def test_unexpected_kwargs_raise_exception(self):
        """Unexpected kwargs on constructor raise exception.

        Test first that we can construct the device.  Then test that
        it fails if there are unused kwargs.  This is an issue when
        there are default arguments, there's a typo on the argument
        name, and the class uses the default instead of an error.  See
        issue #84.
        """
        dummies.TestLightSource()
        # XXX: Device.__del__ calls shutdown().  However, if __init__
        # failed the device is not complete and shutdown() fails
        # because the logger has not been created.  See comments on
        # issue #69.  patch __del__ to workaround this issue.
        with unittest.mock.patch("microscope.devices.Device.__del__"):
            with self.assertRaisesRegex(TypeError, "argument 'power'"):
                dummies.TestLightSource(power=2)
コード例 #3
0
ファイル: test_devices.py プロジェクト: beniroquai/microscope
    def setUp(self):
        self.device = dummies.TestLightSource()

        # TODO: we need to rethink the test so this is not needed.
        self.fake = self.device
        self.fake.default_power = self.fake._set_point
        self.fake.min_power = 0.0
        self.fake.max_power = 100.0