Commit d9896c52 authored by Louis's avatar Louis
Browse files

[cli.test] `pyromaths-cli test update` affiche un diff des fichiers TeX

parent 4bf3b8f7
......@@ -205,6 +205,7 @@ def do_update(options):
test = tests.get(exercise, seed)
if test.changed():
test.show()
test.print_diff()
if ask_confirm("Is the test valid?"):
test.write()
......
......@@ -27,6 +27,7 @@ does just as expected.
"""
import codecs
import difflib
import gettext
import glob
import logging
......@@ -169,6 +170,28 @@ class TestExercise(object):
return True
return False
def print_diff(self):
"""Print the diff between old and new test."""
exo = self.get_exercise()
if "\n".join(exo.tex_statement()) != self.read('statement'):
print("Statement:")
for line in difflib.unified_diff(
self.read('statement'),
"\n".join(exo.tex_statement()),
fromfile='Old statement',
tofile='New statement',
):
print(line)
if "\n".join(exo.tex_answer()) != self.read('answer'):
print("Answer:")
for line in difflib.unified_diff(
self.read('answer').splitlines(),
"\n".join(exo.tex_answer()).splitlines(),
fromfile='Old answer',
tofile='New answer',
):
print(line)
class UnittestExercise(unittest.TestCase):
"""Test an exercise, with a particular seed."""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment