コード例 #1
0
def test():
    url = twilltestlib.get_url()

    # test empty page get_title
    namespaces.new_local_dict()
    twill.commands.reset_browser()
    browser = twill.get_browser()
    try:
        browser.get_title()
        assert 0, "should never get here"
    except TwillException:
        pass

    ### now test a few special cases

    commands.go(url)
    commands.go('/login')

    # test no matching forms
    try:
        commands.fv('2', 'submit', '1')
        assert 0
    except TwillAssertionError:
        pass

    # test regexp match
    commands.fv('1', '.*you', '1')

    # test ambiguous match to value
    commands.go('/testform')
    commands.fv('1', 'selecttest', 'val')
    commands.fv('1', 'selecttest', 'value1')
    commands.fv('1', 'selecttest', 'selvalue1')
    commands.formclear('1')
    commands.showforms()
    try:
        commands.fv('1', 'selecttest', 'value')
        assert 0
    except TwillException:
        pass

    # test ambiguous match to name
    commands.go('/testform')
    try:
        commands.fv('1', 'item_', 'value')
        assert 0
    except Exception:
        pass

    try:
        commands.formfile('1', 'selecttest', 'null')
        assert 0
    except Exception:
        pass

    commands.go('http://www.google.com/')
    browser.get_title()

    # test the twill script.
    twilltestlib.execute_twill_script('test-form.twill', initial_url=url)
コード例 #2
0
ファイル: __init__.py プロジェクト: marta90/Projekt
def setup(package):
    twilltestlib.cd_testdir()
    twilltestlib.run_server(twilltestserver.create_publisher)

    url = twilltestlib.get_url()

    from twill.commands import go, find
    try:
        go(url)
        find("These are the twill tests")
    except:
        raise Exception("\n\n***\n\nHello! The twill test server is not running or cannot be reached; please free port 8080 (or set TWILL_TEST_PORT to something else), and clear your proxy settings too!\n\n***\n\n")
コード例 #3
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-find.twill', initial_url=url)
コード例 #4
0
ファイル: test-broken-html.py プロジェクト: t0ster/twill
def setup_module():
    global url
    url = twilltestlib.get_url()
コード例 #5
0
ファイル: test-form.py プロジェクト: t0ster/twill
def test():
    url = twilltestlib.get_url()
            
    # test empty page get_title
    namespaces.new_local_dict()
    twill.commands.reset_browser()
    browser = twill.get_browser()
    try:
        browser.get_title()
        assert 0, "should never get here"
    except BrowserStateError:
        pass

    ### now test a few special cases
    
    commands.go(url)
    commands.go('/login')
    commands.showforms()

    # test no matching forms
    try:
        commands.fv('2', 'submit', '1')
        assert 0
    except TwillAssertionError:
        pass

    # test regexp match
    commands.fv('1', '.*you', '1')


    # test ambiguous match to value
    commands.go('/testform')
    commands.fv('1', 'selecttest', 'val')
    commands.fv('1', 'selecttest', 'value1')
    commands.fv('1', 'selecttest', 'selvalue1')
    commands.formclear('1')
    try:
        commands.fv('1', 'selecttest', 'value')
        assert 0
    except ClientForm.ItemNotFoundError:
        pass

    # test ambiguous match to name
    commands.go('/testform')
    try:
        commands.fv('1', 'item_', 'value')
        assert 0
    except Exception:
        pass

    try:
        commands.formfile('1', 'selecttest', 'null')
        assert 0
    except Exception:
        pass

    commands.go('http://www.google.com/')
    browser.get_title()

    # test the twill script.
    twilltestlib.execute_twill_script('test-form.twill', initial_url=url)
コード例 #6
0
def setup_module():
    global url
    url = twilltestlib.get_url()
コード例 #7
0
def test():
    url = twilltestlib.get_url()

    if not no_dns_python:
        twilltestlib.execute_twill_script('test-dns.twill', initial_url=url)
コード例 #8
0
ファイル: test-info.py プロジェクト: ArtMatt/twill-ca
def test():
    url = twilltestlib.get_url()
    twilltestlib.execute_twill_script('test-info.twill', initial_url=url)
コード例 #9
0
ファイル: test-http-codes.py プロジェクト: marta90/Projekt
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-http-codes.twill', initial_url=url)
コード例 #10
0
ファイル: test-go.py プロジェクト: ArtMatt/twill-ca
def test():
    url = twilltestlib.get_url()

    # capture output
    fp = StringIO()
    twill.set_output(fp)

    twill.parse.execute_string('code 200', initial_url=url)

    # from file
    twilltestlib.execute_twill_script('test-go.twill', initial_url=url)

    twill.set_output(None)
    assert fp.getvalue()

    ###

    # from stdin
    filename = os.path.join(twilltestlib.testdir, 'test-go.twill')
    old_in, sys.stdin = sys.stdin, open(filename)
    try:
        twilltestlib.execute_twill_script('-', initial_url=url)
    finally:
        sys.stdin = old_in

    # from parse.execute_file
    twill.parse.execute_file('test-go-exit.twill', initial_url=url)
    
    # also test some failures.

    old_err, sys.stderr = sys.stderr, StringIO()
    try:
        twill.set_errout(sys.stderr)
        #
        # failed assert in a script
        #
        try:
            twill.parse.execute_file('test-go-fail.twill', initial_url=url)
            assert 0
        except TwillAssertionError:
            pass

        commands.go(url)
        try:
            commands.code(400)
            assert 0
        except TwillAssertionError:
            pass

        #
        # no such command (NameError)
        #

        try:
            twill.parse.execute_file('test-go-fail2.twill', initial_url=url)
            assert 0
        except TwillNameError, e:
            pass
    finally:
        sys.stderr = old_err

    namespaces.new_local_dict()
    gd, ld = namespaces.get_twill_glocals()

    commands.go(url)
    try:
        twill.parse.execute_command('url', ('not this',), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.follow('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.find('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.notfind('Hello')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        twill.parse.execute_command('exit', ('0',), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except SystemExit:
        pass
コード例 #11
0
ファイル: test-find-xpath.py プロジェクト: brandizzi/retwill
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-find-xpath.twill', initial_url=url)
コード例 #12
0
ファイル: test-equiv-refresh.py プロジェクト: marta90/Projekt
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-equiv-refresh.twill',
                                      initial_url=url)
コード例 #13
0
ファイル: test-http-codes.py プロジェクト: ArtMatt/twill-ca
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-http-codes.twill', initial_url=url)
コード例 #14
0
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-non-string-in-fv-echo.twill', initial_url=url)
コード例 #15
0
ファイル: test-dns.py プロジェクト: ArtMatt/twill-ca
def test():
   url = twilltestlib.get_url()

   if not no_dns_python:
       twilltestlib.execute_twill_script('test-dns.twill', initial_url=url)
コード例 #16
0
def test():
    """
    Test the 'formfill' extension stuff.
    """
    url = twilltestlib.get_url()
    twilltestlib.execute_twill_script('test-formfill.twill', initial_url=url)
コード例 #17
0
def test():
    url = twilltestlib.get_url()

    # capture output
    fp = StringIO()
    twill.set_output(fp)

    twill.parse.execute_string('code 200', initial_url=url)

    # from file
    twilltestlib.execute_twill_script('test-go.twill', initial_url=url)

    twill.set_output(None)
    assert fp.getvalue()

    ###

    # from stdin
    filename = os.path.join(twilltestlib.testdir, 'test-go.twill')
    old_in, sys.stdin = sys.stdin, open(filename)
    try:
        twilltestlib.execute_twill_script('-', initial_url=url)
    finally:
        sys.stdin = old_in

    # from parse.execute_file
    twill.parse.execute_file('test-go-exit.twill', initial_url=url)

    # also test some failures.

    old_err, sys.stderr = sys.stderr, StringIO()
    try:
        twill.set_errout(sys.stderr)
        #
        # failed assert in a script
        #
        try:
            twill.parse.execute_file('test-go-fail.twill', initial_url=url)
            assert 0
        except TwillAssertionError:
            pass

        commands.go(url)
        try:
            commands.code(400)
            assert 0
        except TwillAssertionError:
            pass

        #
        # no such command (NameError)
        #

        try:
            twill.parse.execute_file('test-go-fail2.twill', initial_url=url)
            assert 0
        except TwillNameError, e:
            pass
    finally:
        sys.stderr = old_err

    namespaces.new_local_dict()
    gd, ld = namespaces.get_twill_glocals()

    commands.go(url)
    try:
        twill.parse.execute_command('url', ('not this', ), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.follow('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.find('no such link')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        commands.notfind('Hello')
        assert 0, "shouldn't get here"
    except TwillAssertionError:
        pass

    try:
        twill.parse.execute_command('exit', ('0', ), gd, ld, "anony")
        assert 0, "shouldn't get here"
    except SystemExit:
        pass
コード例 #18
0
def test():
    url = twilltestlib.get_url()
        
    twilltestlib.execute_twill_script('test-dollar-notation-non-strings.twill', initial_url=url)
コード例 #19
0
ファイル: test-global-form.py プロジェクト: marta90/Projekt
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script('test-global-form.twill',
                                      initial_url=url)
コード例 #20
0
def test():
    url = twilltestlib.get_url()

    twilltestlib.execute_twill_script("test-equiv-refresh.twill", initial_url=url)