Commits

Thomas Lotze committed 2e77e63

improved test fixture for sphinx-doc tests: fewer warnings, less repetition

Comments (0)

Files changed (1)

tl/pkg/tests/test_doc.py

 """ % self.package_name)
         subprocess.call([sys.executable, 'setup.py', 'egg_info'])
         self.mkdir('doc')
-        self.write('doc/api.txt', 'dummy')
+        self.write('doc/api.txt', """\
+dummy
+-----
+""")
+        self.write('doc/index.txt', """\
+foo and bar and qux
+
+.. toctree::
+
+    api
+""")
 
     def tearDown(self):
         os.chdir(self.cwd)
 import tl.pkg.sphinxconf
 tl.pkg.sphinxconf.set_defaults()
 """)
-        self.write('doc/index.txt', 'foo and bar and qux')
         tl.pkg.doc.main(['doc'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         self.assertTrue(os.path.isfile(index_html))
 _year_started = 2000
 tl.pkg.sphinxconf.set_defaults()
         """)
-        self.write('doc/index.txt', 'foo and bar and qux')
         tl.pkg.doc.main(['doc'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         contents = open(index_html).read()
 release = '2.0beta'
 tl.pkg.sphinxconf.set_defaults()
         """)
-        self.write('doc/index.txt', 'foo and bar and qux')
         tl.pkg.doc.main(['doc'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         contents = open(index_html).read()
         """)
         os.rename(os.path.join('doc', 'api.txt'),
                   os.path.join('doc', 'api.rst'))
-        self.write('doc/index.rst', 'foo and bar and qux')
+        os.rename(os.path.join('doc', 'index.txt'),
+                  os.path.join('doc', 'index.rst'))
         tl.pkg.doc.main(['doc'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         self.assertTrue(os.path.isfile(index_html))
 release = '2.0beta'
 tl.pkg.sphinxconf.set_defaults()
         """)
-        self.write('doc/index.txt', 'foo and bar and qux')
         tl.pkg.doc.main(['doc', '-D', 'release=3.1.4'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         contents = open(index_html).read()
 project = 'tl.%s'
 tl.pkg.sphinxconf.set_defaults()
 """ % self.package_name)
-        self.write('doc/index.txt', 'foo and bar and qux')
         tl.pkg.doc.main(['doc'])
         index_html = os.path.join(self.tmpdir, 'build/doc/index.html')
         self.assertTrue(os.path.isfile(index_html))