Example #1
0
    def test_parse_term_exceptions(self):
        with pytest.raises(Exception) as e:
            LpReader._parse_term(' -5 5x')
        assert str(
            e.value
        ) == "variable '5x' does not have a valid name: A variable name should not begin with a number or a period"

        with pytest.raises(Exception) as e:
            LpReader._parse_term(' -5 x y')
        assert str(
            e.value
        ) == "variable 'x y' does not have a valid name: A variable name should not have whitespaces"

        with pytest.raises(Exception) as e:
            LpReader._parse_term(' -5 x😂')
        assert str(e.value) == "variable 'x😂' does not have a valid name"
Example #2
0
 def test_parse_term(self, term, expected):
     assert LpReader._parse_term(term) == expected