Ejemplo n.º 1
0
 def reduce(self, code, budget=0):
     assert isinstance(budget, int), budget
     assert budget >= 0, budget
     request = Request()
     request.reduce.code = polish_print(code)
     request.reduce.budget = budget
     reply = self._call(request)
     if not reply.reduce.code:
         raise ValueError('Invalid code: {}'.format(code))
     return {
         'code': polish_parse(str(reply.reduce.code)),
         'budget': int(reply.reduce.budget),
     }
Ejemplo n.º 2
0
def test_polish_serialize_parse(tp, code, value):
    string = polish_print(code)
    assert isinstance(string, str)
    actual_code = polish_parse(string)
    assert actual_code == code
Ejemplo n.º 3
0
def polish_simplify(string):
    return polish_parse(string, SIGNATURE)
Ejemplo n.º 4
0
def test_polish_print_parse(code):
    string = polish_print(code)
    assert isinstance(string, str)
    actual_code = polish_parse(string)
    assert actual_code == code
Ejemplo n.º 5
0
def test_polish_parse(example):
    actual = polish_parse(example['polish'])
    assert actual == example['code']