| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
def _yellow(s): |
| 5 |
return '\033[0;33m' + s + '\033[0m' |
| 6 |
|
| 7 |
def _green(s): |
| 8 |
return '\033[0;32m' + s + '\033[0m' |
| 9 |
|
| 10 |
|
| 11 |
def assert_tableau(func, chaine, attendu, **options): |
| 12 |
resultat = func(chaine, **options) |
| 13 |
if resultat != attendu: |
| 14 |
print("-------") |
| 15 |
for i in range(min(len(resultat), len(attendu))): |
| 16 |
if resultat[i] != attendu[i]: |
| 17 |
break |
| 18 |
resultat = resultat[:i] + _yellow(resultat[i:]) |
| 19 |
attendu = attendu[:i] + _green(attendu[i:]) |
| 20 |
print("ERREUR:") |
| 21 |
print("Expected output was:") |
| 22 |
print(attendu) |
| 23 |
print("While actual result is:") |
| 24 |
print(resultat) |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
print("-------") |
| 34 |
assert (resultat == attendu) |
| 35 |
|