[wwwsearch-commits] r51827 - in wwwsearch/mechanize/trunk: . test
jjlee at codespeak.net
jjlee at codespeak.net
Sat Feb 23 20:11:32 CET 2008
Author: jjlee
Date: Sat Feb 23 20:11:32 2008
New Revision: 51827
Added:
wwwsearch/mechanize/trunk/test/test_password_manager.special_doctest
- copied unchanged from r45426, wwwsearch/mechanize/trunk/test/test_password_manager.doctest
wwwsearch/mechanize/trunk/test/test_robotfileparser.special_doctest
- copied unchanged from r48480, wwwsearch/mechanize/trunk/test/test_robotfileparser.doctest
Removed:
wwwsearch/mechanize/trunk/test/test_password_manager.doctest
wwwsearch/mechanize/trunk/test/test_robotfileparser.doctest
Modified:
wwwsearch/mechanize/trunk/test.py
Log:
Avoid running doctest files that need special context by naming convention rather than special-purpose code
Modified: wwwsearch/mechanize/trunk/test.py
==============================================================================
--- wwwsearch/mechanize/trunk/test.py (original)
+++ wwwsearch/mechanize/trunk/test.py Sat Feb 23 20:11:32 2008
@@ -76,36 +76,23 @@
# run .doctest files needing special support
common_globs = {"mechanize": mechanize}
pm_doctest_filename = os.path.join(
- "test", "test_password_manager.doctest")
+ "test", "test_password_manager.special_doctest")
for globs in [
{"mgr_class": mechanize.HTTPPasswordMgr},
{"mgr_class": mechanize.HTTPProxyPasswordMgr},
]:
globs.update(common_globs)
- doctest.testfile(
- pm_doctest_filename,
- #os.path.join("test", "test_scratch.doctest"),
- globs=globs,
- )
+ doctest.testfile(pm_doctest_filename, globs=globs)
try:
import robotparser
except ImportError:
pass
else:
- doctest.testfile(os.path.join("test",
- "test_robotfileparser.doctest"))
+ doctest.testfile(os.path.join(
+ "test", "test_robotfileparser.special_doctest"))
# run .doctest files
- special_doctests = [pm_doctest_filename,
- os.path.join("test", "test_scratch.doctest"),
- os.path.join("test",
- "test_robotfileparser.doctest"),
- ]
doctest_files = glob.glob(os.path.join("test", "*.doctest"))
-
- for dt in special_doctests:
- if dt in doctest_files:
- doctest_files.remove(dt)
for df in doctest_files:
doctest.testfile(df)
Deleted: /wwwsearch/mechanize/trunk/test/test_password_manager.doctest
==============================================================================
--- /wwwsearch/mechanize/trunk/test/test_password_manager.doctest Sat Feb 23 20:11:32 2008
+++ (empty file)
@@ -1,148 +0,0 @@
-Features common to HTTPPasswordMgr and HTTPProxyPasswordMgr
-===========================================================
-
-(mgr_class gets here through globs argument)
-
->>> mgr = mgr_class()
->>> add = mgr.add_password
-
->>> add("Some Realm", "http://example.com/", "joe", "password")
->>> add("Some Realm", "http://example.com/ni", "ni", "ni")
->>> add("c", "http://example.com/foo", "foo", "ni")
->>> add("c", "http://example.com/bar", "bar", "nini")
->>> add("b", "http://example.com/", "first", "blah")
->>> add("b", "http://example.com/", "second", "spam")
->>> add("a", "http://example.com", "1", "a")
->>> add("Some Realm", "http://c.example.com:3128", "3", "c")
->>> add("Some Realm", "d.example.com", "4", "d")
->>> add("Some Realm", "e.example.com:3128", "5", "e")
-
->>> mgr.find_user_password("Some Realm", "example.com")
-('joe', 'password')
->>> mgr.find_user_password("Some Realm", "http://example.com")
-('joe', 'password')
->>> mgr.find_user_password("Some Realm", "http://example.com/")
-('joe', 'password')
->>> mgr.find_user_password("Some Realm", "http://example.com/spam")
-('joe', 'password')
->>> mgr.find_user_password("Some Realm", "http://example.com/spam/spam")
-('joe', 'password')
->>> mgr.find_user_password("c", "http://example.com/foo")
-('foo', 'ni')
->>> mgr.find_user_password("c", "http://example.com/bar")
-('bar', 'nini')
-
-Actually, this is really undefined ATM
-#Currently, we use the highest-level path where more than one match:
-#
-#>>> mgr.find_user_password("Some Realm", "http://example.com/ni")
-#('joe', 'password')
-
-Use latest add_password() in case of conflict:
-
->>> mgr.find_user_password("b", "http://example.com/")
-('second', 'spam')
-
-No special relationship between a.example.com and example.com:
-
->>> mgr.find_user_password("a", "http://example.com/")
-('1', 'a')
->>> mgr.find_user_password("a", "http://a.example.com/")
-(None, None)
-
-Ports:
-
->>> mgr.find_user_password("Some Realm", "c.example.com")
-(None, None)
->>> mgr.find_user_password("Some Realm", "c.example.com:3128")
-('3', 'c')
->>> mgr.find_user_password("Some Realm", "http://c.example.com:3128")
-('3', 'c')
->>> mgr.find_user_password("Some Realm", "d.example.com")
-('4', 'd')
->>> mgr.find_user_password("Some Realm", "e.example.com:3128")
-('5', 'e')
-
-
-Default port tests
-------------------
-
->>> mgr = mgr_class()
->>> add = mgr.add_password
-
-The point to note here is that we can't guess the default port if there's
-no scheme. This applies to both add_password and find_user_password.
-
->>> add("f", "http://g.example.com:80", "10", "j")
->>> add("g", "http://h.example.com", "11", "k")
->>> add("h", "i.example.com:80", "12", "l")
->>> add("i", "j.example.com", "13", "m")
->>> mgr.find_user_password("f", "g.example.com:100")
-(None, None)
->>> mgr.find_user_password("f", "g.example.com:80")
-('10', 'j')
->>> mgr.find_user_password("f", "g.example.com")
-(None, None)
->>> mgr.find_user_password("f", "http://g.example.com:100")
-(None, None)
->>> mgr.find_user_password("f", "http://g.example.com:80")
-('10', 'j')
->>> mgr.find_user_password("f", "http://g.example.com")
-('10', 'j')
->>> mgr.find_user_password("g", "h.example.com")
-('11', 'k')
->>> mgr.find_user_password("g", "h.example.com:80")
-('11', 'k')
->>> mgr.find_user_password("g", "http://h.example.com:80")
-('11', 'k')
->>> mgr.find_user_password("h", "i.example.com")
-(None, None)
->>> mgr.find_user_password("h", "i.example.com:80")
-('12', 'l')
->>> mgr.find_user_password("h", "http://i.example.com:80")
-('12', 'l')
->>> mgr.find_user_password("i", "j.example.com")
-('13', 'm')
->>> mgr.find_user_password("i", "j.example.com:80")
-(None, None)
->>> mgr.find_user_password("i", "http://j.example.com")
-('13', 'm')
->>> mgr.find_user_password("i", "http://j.example.com:80")
-(None, None)
-
-
-Features specific to HTTPProxyPasswordMgr
-=========================================
-
-Default realm:
-
->>> mgr = mechanize.HTTPProxyPasswordMgr()
->>> add = mgr.add_password
-
->>> mgr.find_user_password("d", "f.example.com")
-(None, None)
->>> add(None, "f.example.com", "6", "f")
->>> mgr.find_user_password("d", "f.example.com")
-('6', 'f')
-
-Default host/port:
-
->>> mgr.find_user_password("e", "g.example.com")
-(None, None)
->>> add("e", None, "7", "g")
->>> mgr.find_user_password("e", "g.example.com")
-('7', 'g')
-
-Default realm and host/port:
-
->>> mgr.find_user_password("f", "h.example.com")
-(None, None)
->>> add(None, None, "8", "h")
->>> mgr.find_user_password("f", "h.example.com")
-('8', 'h')
-
-Default realm beats default host/port:
-
->>> add("d", None, "9", "i")
->>> mgr.find_user_password("d", "f.example.com")
-('6', 'f')
Deleted: /wwwsearch/mechanize/trunk/test/test_robotfileparser.doctest
==============================================================================
--- /wwwsearch/mechanize/trunk/test/test_robotfileparser.doctest Sat Feb 23 20:11:32 2008
+++ (empty file)
@@ -1,8 +0,0 @@
->>> from mechanize._http import MechanizeRobotFileParser
-
-Calling .set_opener() without args sets a default opener.
-
->>> rfp = MechanizeRobotFileParser()
->>> rfp.set_opener()
->>> rfp._opener # doctest: +ELLIPSIS
-<mechanize._opener.OpenerDirector instance at ...>
More information about the wwwsearch-commits
mailing list