From ffd2a55b659b3cf8f2f0e5af14fb34ac88fcd33c Mon Sep 17 00:00:00 2001 From: lafrite Date: Wed, 3 Dec 2014 15:52:08 +0100 Subject: [PATCH] add doctest in random_expression --- pymath/random_expression.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pymath/random_expression.py b/pymath/random_expression.py index 32935a6..a638744 100644 --- a/pymath/random_expression.py +++ b/pymath/random_expression.py @@ -31,6 +31,19 @@ class RdExpression(object): @classmethod def set_form(cls, form): + """ Define whether RdExpression create expression with Expression (nice render) or if it only replace inside {} not taking care or render + + >>> form = "{a}*{b}" + >>> exp = RdExpression(form)() + >>> print(type(exp)) + + >>> RdExpression.set_form("raw") + >>> form = "{a}*{b}" + >>> exp = RdExpression(form)() + >>> print(type(exp)) + + """ + cls.FORM = form @classmethod @@ -189,12 +202,13 @@ if __name__ == '__main__': rdExp3 = RdExpression(form, cond) desc_rdExp(rdExp3) - form = "{a + a*10}*4 + {a} + 2*{b}" + form = "{a+a*10}*4 + {a} + 2*{b}" cond = ["{a-b} + {b} in list(range(20))", "abs({a}) not in [1]", "{b} not in [1]", "gcd({a},{b}) == 1"] rdExp3 = RdExpression(form, cond) desc_rdExp(rdExp3) - + import doctest + doctest.testmod()