コード例 #1
0
    def test__check_proposals_proposals_gt_cardinality(self):
        """Test that ``ValueError`` is being raised if ``proposals`` is greater than
        ``self.tunable.cardinality``.
        """
        # setup
        instance = MagicMock()
        instance.tunable.cardinality = 4

        # run / assert
        with self.assertRaises(ValueError):
            BaseTuner._check_proposals(instance, 5)
コード例 #2
0
    def test__check_proposals_trials_and_proposals_gt_cardinality(self):
        """Test that ``ValueError`` is being raised if ``proposals`` + ``len(self.trials)``
        is greater than ``self.tunable.cardinality``.
        """
        # setup
        instance = MagicMock()
        instance.tunable.cardinality = 4
        instance._trials_set.__len__.return_value = 2

        # run / assert
        with self.assertRaises(ValueError):
            BaseTuner._check_proposals(instance, 3)
コード例 #3
0
    def test__check_proposals_trials_eq_cardinality(self):
        """Test that ``ValueError`` is being raised if ``self.trials`` is equal to
        ``self.tunable.cardinality``.
        """
        # setup
        instance = MagicMock()
        instance.tunable.cardinality = 2
        instance._trials_set.__len__.return_value = 2

        # run / assert
        with self.assertRaises(ValueError):
            BaseTuner._check_proposals(instance, 1)
コード例 #4
0
    def test__check_proposals_not_raise(self):
        """Test that ``ValueError`` is not being raised."""
        # setup
        instance = MagicMock()
        instance.tunable.cardinality = 4
        instance._trials_set.__len__.return_value = 2

        # run / assert
        result = BaseTuner._check_proposals(instance, 1)
        assert result is None