Author: grubert
Date: 2010-07-10 08:46:56 +0200 (Sat, 10 Jul 2010)
New Revision: 6367
Added:
trunk/docutils/tools/test/
trunk/docutils/tools/test/test_buildhtml.py
Modified:
trunk/docutils/HISTORY.txt
Log:
add test for build_html ignoring --local
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2010-07-09 19:00:18 UTC (rev 6366)
+++ trunk/docutils/HISTORY.txt 2010-07-10 06:46:56 UTC (rev 6367)
@@ -17,6 +17,10 @@
Changes Since 0.7
=================
+* tools/buildhtml.py:
+
+ -- Fix ``--local`` switch.
+
Release 0.7 (2010-07-07)
========================
Added: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py (rev 0)
+++ trunk/docutils/tools/test/test_buildhtml.py 2010-07-10 06:46:56 UTC (rev 6367)
@@ -0,0 +1,87 @@
+#!/usr/bin/python
+
+"""
+test buildhtml options, because ``--local`` is broken.
+
+Build-HTML Options
+------------------
+--recurse Recursively scan subdirectories for files to process.
+ This is the default.
+--local Do not scan subdirectories for files to process.
+--prune=<directory> Do not process files in <directory>. This option may
+ be used more than once to specify multiple
+ directories.
+--ignore=<patterns> Recursively ignore files or directories matching any
+ of the given wildcard (shell globbing) patterns
+ (separated by colons). Default: ".svn:CVS"
+--silent Work silently (no progress messages). Independent of
+ "--quiet".
+"""
+
+import unittest
+import os
+import re
+
+def process_and_return_filelist(options):
+ dirs = []
+ files = []
+ cin, cout = os.popen4("../buildhtml.py "+options)
+ while 1:
+ ln = cout.readline()
+ if not ln:
+ break
+ # BUG no colon in filename/path allowed
+ item = ln.split(":")[-1].strip()
+ if ln.startswith(" "):
+ files.append(item)
+ else:
+ dirs.append(item)
+ return (dirs, files)
+
+class BuildHtmlTests(unittest.TestCase):
+ tree = ( "_tmp_test_tree",
+ "_tmp_test_tree/one.txt",
+ "_tmp_test_tree/two.txt",
+ "_tmp_test_tree/dir1",
+ "_tmp_test_tree/dir1/one.txt",
+ "_tmp_test_tree/dir1/two.txt",
+ "_tmp_test_tree/dir2",
+ "_tmp_test_tree/dir2/one.txt",
+ "_tmp_test_tree/dir2/two.txt",
+ "_tmp_test_tree/dir2/sub",
+ "_tmp_test_tree/dir2/sub/one.txt",
+ "_tmp_test_tree/dir2/sub/two.txt",
+ )
+
+ def setUp(self):
+ self.root = os.tempnam()
+ os.mkdir(self.root)
+ for s in self.tree:
+ s = os.path.join(self.root, s)
+ if not "." in s:
+ os.mkdir(s)
+ else:
+ open(s, "w").write("dummy")
+
+ def tearDown(self):
+ for i in range(len(self.tree) - 1, -1, -1):
+ s = os.path.join(self.root, self.tree[i])
+ if not "." in s:
+ os.rmdir(s)
+ else:
+ os.remove(s)
+ os.rmdir(self.root)
+
+ def test_1(self):
+ opts = "--dry-run "+ self.root
+ dirs, files = process_and_return_filelist( opts )
+ self.assertEquals(files.count("one.txt"), 4)
+
+ def test_local(self):
+ opts = "--dry-run --local "+ self.root
+ dirs, files = process_and_return_filelist( opts )
+ self.assertEquals( len(dirs), 5)
+ self.assertEquals( len(files), 8)
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: trunk/docutils/tools/test/test_buildhtml.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
|