示例#1
0
 def background_type(self, value):
     if isinstance(value, str):
         self.background_combo_box.setCurrentIndex(
             BackgroundType.from_string(value))
     elif isinstance(value, int):
         self.background_combo_box.setCurrentIndex(value)
     else:
         raise TypeError(
             'background_type must either be a string or an int')
示例#2
0
    def test_background_type_from_string(self):
        """
        Test the from_string method of :class:`BackgroundType`
        """
        # GIVEN: The BackgroundType strings
        background_type_solid = 'solid'
        background_type_gradient = 'gradient'
        background_type_image = 'image'
        background_type_transparent = 'transparent'
        background_type_video = 'video'
        background_type_stream = 'stream'

        # WHEN: Calling BackgroundType.from_string
        # THEN: The enum equivalents should be returned
        assert BackgroundType.from_string(
            background_type_solid) == BackgroundType.Solid
        assert BackgroundType.from_string(
            background_type_gradient) == BackgroundType.Gradient
        assert BackgroundType.from_string(
            background_type_image) == BackgroundType.Image
        assert BackgroundType.from_string(
            background_type_transparent) == BackgroundType.Transparent
        assert BackgroundType.from_string(
            background_type_video) == BackgroundType.Video
        assert BackgroundType.from_string(
            background_type_stream) == BackgroundType.Stream