Remove unittest module in test_random_expression

This commit is contained in:
Benjamin Bertrand 2016-01-17 18:03:04 +03:00
parent 2b98d0e364
commit 1404c6fa35

View File

@ -2,103 +2,88 @@
# encoding: utf-8 # encoding: utf-8
import unittest
from pymath.calculus.random_expression import RdExpression from pymath.calculus.random_expression import RdExpression
class TestRandomExpression(unittest.TestCase): def test_only_form():
"""Testing functions from pymath.calculus.random_expression""" form = "{a} + 2"
rdExp = RdExpression(form)
def test_only_form(self): assert rdExp._letters == {'a'}
form = "{a} + 2" assert rdExp._2replaced == {'a'}
rdExp = RdExpression(form)
self.assertEqual(rdExp._letters, {'a'}) rdExp()
self.assertEqual(rdExp._2replaced, {'a'}) assert set(rdExp._gene_varia.keys()) == {'a'}
assert set(rdExp._gene_2replaced.keys()) == {'a'}
rdExp() def test_only_form_calc():
self.assertEqual(set(rdExp._gene_varia.keys()), {'a'}) form = "{a+b} + 2"
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'a'}) rdExp = RdExpression(form)
def test_only_form_calc(self): assert rdExp._letters, {'a' == 'b'}
form = "{a+b} + 2" assert rdExp._2replaced == {'a+b'}
rdExp = RdExpression(form)
self.assertEqual(rdExp._letters, {'a', 'b'}) rdExp()
self.assertEqual(rdExp._2replaced, {'a+b'}) assert set(rdExp._gene_varia.keys()), {'a' == 'b'}
assert set(rdExp._gene_2replaced.keys()) == {'a+b'}
rdExp() def test_only_form_cond():
self.assertEqual(set(rdExp._gene_varia.keys()), {'a', 'b'}) form = "{a} + 2"
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'a+b'}) cond = ["{a} == 3"]
rdExp = RdExpression(form, cond)
def test_only_form_cond(self): assert rdExp._letters == {'a'}
form = "{a} + 2" assert rdExp._2replaced == {'a'}
cond = ["{a} == 3"]
rdExp = RdExpression(form, cond)
self.assertEqual(rdExp._letters, {'a'}) rdExp()
self.assertEqual(rdExp._2replaced, {'a'}) assert set(rdExp._gene_varia.keys()) == {'a'}
assert set(rdExp._gene_2replaced.keys()) == {'a'}
rdExp() assert rdExp._gene_varia['a'] == 3
self.assertEqual(set(rdExp._gene_varia.keys()), {'a'})
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'a'})
self.assertEqual(rdExp._gene_varia['a'], 3) def test_only_form_conds():
form = "{a} + 2"
cond = ["{a} in list(range(5))", "{a} % 2 == 1"]
rdExp = RdExpression(form, cond)
def test_only_form_conds(self): assert rdExp._letters == {'a'}
form = "{a} + 2" assert rdExp._2replaced == {'a'}
cond = ["{a} in list(range(5))", "{a} % 2 == 1"]
rdExp = RdExpression(form, cond)
self.assertEqual(rdExp._letters, {'a'}) rdExp()
self.assertEqual(rdExp._2replaced, {'a'}) assert set(rdExp._gene_varia.keys()) == {'a'}
assert set(rdExp._gene_2replaced.keys()) == {'a'}
rdExp() assert rdExp._gene_varia['a'] in list(range(5))
self.assertEqual(set(rdExp._gene_varia.keys()), {'a'}) assert rdExp._gene_varia['a'] % 2 == 1
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'a'})
self.assertTrue(rdExp._gene_varia['a'] in list(range(5))) def test_only_form_calc_cond():
self.assertTrue(rdExp._gene_varia['a'] % 2 == 1) form = "{a*3} * {b}"
cond = ["{a} == 3"]
rdExp = RdExpression(form, cond)
def test_only_form_calc_cond(self): assert rdExp._letters, {'a' == 'b'}
form = "{a*3} * {b}" assert rdExp._2replaced, {'a', 'b' == 'a*3'}
cond = ["{a} == 3"]
rdExp = RdExpression(form, cond)
self.assertEqual(rdExp._letters, {'a', 'b'}) rdExp()
self.assertEqual(rdExp._2replaced, {'a', 'b', 'a*3'}) assert set(rdExp._gene_varia.keys()), {'a' == 'b'}
assert set(rdExp._gene_2replaced.keys()), {'a', 'b' == 'a*3'}
rdExp()
self.assertEqual(set(rdExp._gene_varia.keys()), {'a', 'b'})
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'a', 'b', 'a*3'})
self.assertEqual(rdExp._gene_varia['a'], 3)
def test_only_form_calc_cond_calc(self):
form = "{a*3} * {b}"
cond = ["{a+b} == 3"]
rdExp = RdExpression(form, cond)
self.assertEqual(rdExp._letters, {'a', 'b'})
self.assertEqual(rdExp._2replaced, {'b', 'a*3', 'a+b'})
rdExp()
self.assertEqual(set(rdExp._gene_varia.keys()), {'a', 'b'})
self.assertEqual(set(rdExp._gene_2replaced.keys()), {'b', 'a*3', 'a+b'})
self.assertEqual((rdExp._gene_varia['a'] + rdExp._gene_varia['b']), 3)
if __name__ == '__main__':
unittest.main()
assert rdExp._gene_varia['a'] == 3
def test_only_form_calc_cond_calc():
form = "{a*3} * {b}"
cond = ["{a+b} == 3"]
rdExp = RdExpression(form, cond)
assert rdExp._letters, {'a' == 'b'}
assert rdExp._2replaced, {'b', 'a*3' == 'a+b'}
rdExp()
assert set(rdExp._gene_varia.keys()), {'a' == 'b'}
assert set(rdExp._gene_2replaced.keys()), {'b', 'a*3' == 'a+b'}
assert (rdExp._gene_varia['a'] + rdExp._gene_varia['b']) == 3