up format typo
This commit is contained in:
parent
2f4045a98d
commit
6af9d635de
4 changed files with 95 additions and 16 deletions
43
test_format_typo.py
Normal file
43
test_format_typo.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
import unittest
|
||||
import re
|
||||
|
||||
# Supposons que format_typo.py soit dans le même répertoire
|
||||
from format_typo import corriger_typo
|
||||
|
||||
def test_correction_entetes_org(self):
|
||||
texte_avec_entetes = """* chapitre 1 :titre:
|
||||
* chapitre 2 : titre :"""
|
||||
texte_corrige = corriger_typo(texte_avec_entetes)
|
||||
self.assertEqual(texte_corrige, """* chapitre 1 :titre:
|
||||
* chapitre 2 :titre:""")
|
||||
|
||||
|
||||
class TestFormatTypo(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Texte Org-mode fictif pour les tests
|
||||
self.texte_org = """
|
||||
* chapitre 1
|
||||
ceci est un texte sans majuscule au début de la phrase.
|
||||
|
||||
* chapitre 2
|
||||
il y a trop de sauts de ligne ici.
|
||||
|
||||
|
||||
* chapitre 3
|
||||
il manque des espaces autour de la ponctuation:voici un exemple.
|
||||
"""
|
||||
|
||||
def test_correction_majuscules(self):
|
||||
texte_corrige = corriger_typo(self.texte_org)
|
||||
self.assertIn("Ceci est un texte sans majuscule", texte_corrige)
|
||||
|
||||
def test_correction_sauts_de_ligne(self):
|
||||
texte_corrige = corriger_typo(self.texte_org)
|
||||
self.assertNotIn("\n\n\n", texte_corrige)
|
||||
|
||||
def test_correction_espaces_ponctuation(self):
|
||||
texte_corrige = corriger_typo(self.texte_org)
|
||||
self.assertIn(": voici un exemple.", texte_corrige)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
Add table
Add a link
Reference in a new issue