Пример #1
0
    def test_enable_missing_features(self):
        """
        Test that the `enable_features` method correctly raises an error on a non-existent feature
        """
        # GIVEN: An instance of FontSelectPage with some mocks
        instance = FontSelectPage()
        mock_label = MagicMock()
        mock_control = MagicMock()
        instance.feature_widgets = {'test1': [mock_label, mock_control]}

        # WHEN: The "test" feature is enabled
        with pytest.raises(KeyError, match='No such feature'):
            instance.enable_features('test2')
Пример #2
0
    def test_enable_features(self):
        """
        Test that the `enable_features` method correctly enables widgets based on features
        """
        # GIVEN: An instance of FontSelectPage with some mocks
        instance = FontSelectPage()
        mock_label = MagicMock()
        mock_control = MagicMock()
        instance.feature_widgets = {'test': [mock_label, mock_control]}

        # WHEN: The "test" feature is enabled
        instance.enable_features('test')

        # THEN: "show()" is called on all the widgets
        mock_label.show.assert_called_once()
        mock_control.show.assert_called_once()