1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| class GoodError(ValueError):
pass
def TestGoodFormula(oneGoodFomula):
try:
mathFormula.parser(oneGoodFomula)
eveythingSeemsOk = True
except:
print('',
' --->> ' + oneGoodFomula + ' <<---',
sep = '\n')
eveythingSeemsOk = False
if eveythingSeemsOk:
raise GoodError
class MathFormulaGoodInput(unittest.TestCase):
good_formulas = [
# SIMPLE THINGS
'1,4',
'(7)',
'4+7',
'(x) + 4',
'(-2x + 4)',
'3**x**2',
'(3+2)**[x+5]**{2-4}',
'(1+5)/(7-5)',
# FUNCTIONS
'cos x',
'cos(x)',
'cos(x+4)',
]
def test_good_formula(self):
sys.stdout.write('')
for oneGoodFomula in self.good_formulas:
self.assertRaises(GoodError, TestGoodFormula, oneGoodFomula) |
Partager