Exemple #1
0
    def test_write_only_parameter(self):
        parameter = Parameter('foo', fset=empty_setter)
        self.assertTrue(parameter.is_writable())
        self.assertFalse(parameter.is_readable())

        parameter.set(1).result()

        with self.assertRaises(ReadAccessError) as ctx:
            parameter.get().result()

        self.assertEqual("parameter `foo' cannot be read", str(ctx.exception))
Exemple #2
0
    def test_read_only_parameter(self):
        def getter():
            return 0

        parameter = Parameter('foo', fget=getter)
        self.assertTrue(parameter.is_readable())
        self.assertFalse(parameter.is_writable())

        self.assertEqual(parameter.get().result(), 0)

        with self.assertRaises(WriteAccessError) as ctx:
            parameter.set(None).result()

        self.assertEqual("parameter `foo' cannot be written",
                         str(ctx.exception))