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()