mailr18914 - /trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on March 20, 2013 - 14:58:
Author: bugman
Date: Wed Mar 20 14:58:16 2013
New Revision: 18914

URL: http://svn.gna.org/viewcvs/relax?rev=18914&view=rev
Log:
Expanded the unit testing of the lib.text.sectioning module to cover all 
title and section functions.


Modified:
    trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py

Modified: trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py?rev=18914&r1=18913&r2=18914&view=diff
==============================================================================
--- trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py (original)
+++ trunk/test_suite/unit_tests/_lib/_text/test_sectioning.py Wed Mar 20 
14:58:16 2013
@@ -23,12 +23,106 @@
 from unittest import TestCase
 
 # relax module imports.
-from lib.text.sectioning import subtitle, title
+from lib.text.sectioning import section, subsection, subsubsection, 
subsubtitle, subtitle, title
 from relax_io import DummyFileObject
 
 
 class Test_sectioning(TestCase):
     """Unit tests for the lib.text.sectioning relax module."""
+
+    def test_section(self):
+        """Test of the lib.text.sectioning.section() function."""
+
+        # Write out the section.
+        file = DummyFileObject()
+        section(file=file, text='Test section')
+
+        # Read the results.
+        lines = file.readlines()
+        print("Formatted section lines:  %s" % lines)
+
+        # Check the title.
+        real_lines = [
+            '\n',
+            '\n',
+            'Test section\n',
+            '============\n',
+            '\n',
+        ]
+        self.assertEqual(len(lines), len(real_lines))
+        for i in range(len(lines)):
+            self.assertEqual(lines[i], real_lines[i])
+
+
+    def test_subsection(self):
+        """Test of the lib.text.sectioning.subsection() function."""
+
+        # Write out the subsection.
+        file = DummyFileObject()
+        subsection(file=file, text='Test subsection')
+
+        # Read the results.
+        lines = file.readlines()
+        print("Formatted subsection lines:  %s" % lines)
+
+        # Check the title.
+        real_lines = [
+            '\n',
+            'Test subsection\n',
+            '---------------\n',
+            '\n',
+        ]
+        self.assertEqual(len(lines), len(real_lines))
+        for i in range(len(lines)):
+            self.assertEqual(lines[i], real_lines[i])
+
+
+    def test_subsubsection(self):
+        """Test of the lib.text.sectioning.subsubsection() function."""
+
+        # Write out the subsubsection.
+        file = DummyFileObject()
+        subsubsection(file=file, text='Test subsubsection')
+
+        # Read the results.
+        lines = file.readlines()
+        print("Formatted subsubsection lines:  %s" % lines)
+
+        # Check the title.
+        real_lines = [
+            '\n',
+            'Test subsubsection\n',
+            '~~~~~~~~~~~~~~~~~~\n',
+            '\n',
+        ]
+        self.assertEqual(len(lines), len(real_lines))
+        for i in range(len(lines)):
+            self.assertEqual(lines[i], real_lines[i])
+
+
+    def test_subsubtitle(self):
+        """Test of the lib.text.sectioning.subsubtitle() function."""
+
+        # Write out the subtitle.
+        file = DummyFileObject()
+        subsubtitle(file=file, text='Test subsubtitle')
+
+        # Read the results.
+        lines = file.readlines()
+        print("Formatted subsubtitle lines:  %s" % lines)
+
+        # Check the title.
+        real_lines = [
+            '\n',
+            '~~~~~~~~~~~~~~~~~~~~\n',
+            '~ Test subsubtitle ~\n',
+            '~~~~~~~~~~~~~~~~~~~~\n',
+            '\n',
+        ]
+        self.assertEqual(len(lines), len(real_lines))
+        for i in range(len(lines)):
+            self.assertEqual(lines[i], real_lines[i])
+
 
     def test_subtitle(self):
         """Test of the lib.text.sectioning.subtitle() function."""
@@ -42,15 +136,16 @@
         print("Formatted subtitle lines:  %s" % lines)
 
         # Check the title.
-        subtitle_lines = [
+        real_lines = [
             '\n',
-            '# Test subtitle\n',
-            '###############\n',
+            '-----------------\n',
+            '- Test subtitle -\n',
+            '-----------------\n',
             '\n',
         ]
-        self.assertEqual(len(lines), len(subtitle_lines))
+        self.assertEqual(len(lines), len(real_lines))
         for i in range(len(lines)):
-            self.assertEqual(lines[i], subtitle_lines[i])
+            self.assertEqual(lines[i], real_lines[i])
 
 
     def test_title(self):
@@ -65,14 +160,14 @@
         print("Formatted title lines:  %s" % lines)
 
         # Check the title.
-        title_lines = [
+        real_lines = [
             '\n',
             '\n',
-            '##############\n',
-            '# Test title #\n',
-            '##############\n',
+            '==============\n',
+            '= Test title =\n',
+            '==============\n',
             '\n',
         ]
-        self.assertEqual(len(lines), len(title_lines))
+        self.assertEqual(len(lines), len(real_lines))
         for i in range(len(lines)):
-            self.assertEqual(lines[i], title_lines[i])
+            self.assertEqual(lines[i], real_lines[i])




Related Messages


Powered by MHonArc, Updated Wed Mar 20 15:00:02 2013