1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
"""
Test a boatload of miscellaneous functionality.
"""
import sys
import twilltestlib
import twill, twill.browser, twill.commands
from cStringIO import StringIO
from twill.errors import TwillAssertionError
import urllib2
def setup_module():
pass
def ensure_fail_on_gopher_import():
try:
from mechanize import GopherError
assert 0, "GopherError and gopherlib are no longer in python 2.6"
except ImportError:
pass
def test():
# reset
twill.commands.reset_browser()
# get the current browser obj.
browser = twill.get_browser()
assert browser is twill.commands.browser
# check the 'None' value of return code
assert browser.get_code() is None
# no forms, right?
try:
browser.submit()
except Exception:
pass
try:
import warnings
warnings.filterwarnings('ignore')
assert browser is twill.get_browser_state() # deprecated
warnings.resetwarnings()
except DeprecationWarning:
pass
old_err, sys.stderr = sys.stderr, StringIO()
try:
try:
browser.go('http://') # what's a good "nowhere"?!?
assert 0, "shouldn't get here"
except:
pass
finally:
sys.stderr = old_err
try:
twill.commands.exit()
assert 0, "shouldn't get here"
except SystemExit:
pass
try:
twill.commands.reset_browser()
twill.commands.showhistory()
twill.commands.tidy_ok()
twill.commands.show()
assert 0, "shouldn't get here!" # no page!
except TwillAssertionError:
pass
twill.commands.debug('http', '1')
twill.commands.debug('http', '0')
twill.commands.debug('http', '+')
twill.commands.debug('http', '-')
twill.commands.debug('commands', '0')
twill.commands.debug('commands', '1')
try:
twill.commands.debug('nada', '1')
assert 0
except:
pass
twill.commands.config()
twill.commands.config('readonly_controls_writeable')
twill.commands.config('use_tidy')
twill.commands.config('require_tidy')
twill.commands.config('readonly_controls_writeable', 1)
twill.commands.config('use_tidy', 1)
twill.commands.config('require_tidy', 0)
twill.commands.config('require_tidy', "on")
twill.commands.run("print 'hello'")
def teardown_module():
pass
|