Skip to content
Snippets Groups Projects
Commit 81ebc110 authored by Eliott Sammier's avatar Eliott Sammier
Browse files

Rework: tests now run using all files in the tests dir

parent 9f3cd0c3
No related branches found
No related tags found
No related merge requests found
import subprocess import subprocess
import unittest import unittest
from pathlib import Path
from common import RESULT_DIR from common import RESULT_DIR
TESTS_DIR = RESULT_DIR + "/../tests" TESTS_DIR = Path(RESULT_DIR + "/../tests").resolve()
class ConversionTest(unittest.TestCase): class CompareFiles(unittest.TestCase):
"""A test case that takes a file from `TESTS_DIR`, finds the corresponding
def filediff(self, expected, actual): file in the generated results (in `RESULT_DIR`) and compares them using
diffcmd = subprocess.run(["diff", "--color=always", "-u", expected, actual]) `diff`, printing the full diff if they're not identical.
"""
def __init__(self, expected: Path) -> None:
super().__init__()
self.expected = expected
def runTest(self):
# ex: for a file `TESTS_DIR/pg60/index.md`, will find the first file in
# `RESULT_DIR` whose path ends with `pg60/index.md`
relative = self.expected.relative_to(TESTS_DIR)
cmd = subprocess.run(
[
"find",
RESULT_DIR + "/activities",
"-path",
f"*/{relative}",
],
check=True,
capture_output=True,
encoding="utf-8",
)
actual = cmd.stdout.splitlines()[0]
# Any exceptions in the lookup above cause the test case to fail, this
# is what we want.
# Run the diff between the two files, without `capture_output=True`,
# therefore the diff is printed to the console
diffcmd = subprocess.run(
["diff", "--color=always", "-u", self.expected, actual]
)
self.assertEqual(diffcmd.returncode, 0, "see diff output above.") self.assertEqual(diffcmd.returncode, 0, "see diff output above.")
def test_pass(self):
self.filediff(
TESTS_DIR + "/pg60/quiz.json",
TESTS_DIR + "/pg60/quiz.json",
)
def test_fail(self): class ConversionTests(unittest.TestSuite):
self.filediff( """A test suite that checks all files in the tests directory, and tries
TESTS_DIR + "/pg60/quiz.json", to compare it with its generated counterpart"""
RESULT_DIR + "/activities/MosMod10/MosMod11/MosEtp129/pg60/quiz.json",
) def __init__(self, tests) -> None:
super().__init__(tests)
for file in TESTS_DIR.rglob("*"): # Recursively find all files
if file.is_file():
self.addTest(CompareFiles(file))
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() runner = unittest.TextTestRunner()
runner.run(ConversionTests([]))
+++
title = "L'auxiliaire WILL (2)"
weight = 40
+++
<table>
<tr>
<td>
<audio src="e29_macao1_2a3.mp3"></audio>
</td>
<td>"Will you post this letter tomorrow?"<br>"Don't worry, I will see to it."</td>
</tr>
<tr>
<td>
<audio src="e29_macao1_2a4.mp3"></audio>
</td>
<td>"Will you come?"<br>"Yes, I will."</td>
</tr>
</table>
Dans la réponse de chaque dialogue, l'auxiliaire WILL est-il prononcé de façon identique ? Ecoutez de nouveau les
réponses et sélectionnez l'un des deux choix :
{{< quiz >}}
{
"elements": [
{
"name": "pg8251",
"type": "radiogroup",
"choices": [
{
"value": 0,
"text": "l'auxiliaire WILL est prononcé de façon identique."
},
{
"value": 1,
"text": "l'auxiliaire WILL n'est pas prononcé de façon identique."
}
],
"correctAnswer": 1,
"correctComment": "Bien !\n\nL'auxiliaire de la première réponse comporte une voyelle réduite ; ce n'est pas le cas de la deuxième réponse.",
"incorrectComment": "Non. Vous vous êtes trompé\n\nL'auxiliaire de la première réponse comporte une voyelle réduite ; ce n'est pas le cas de la deuxième réponse. Vous pouvez réécouter chaque énoncé en cliquant sur le haut-parleur."
}
]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment