|
Last change
on this file since 7604 was
7541,
checked in by uli, 15 years ago
|
|
Add sources copied from current multi-mechanize GIT repos.
|
|
File size:
718 bytes
|
| Line | |
|---|
| 1 | # |
|---|
| 2 | # Copyright (c) 2010 Corey Goldberg (corey@goldb.org) |
|---|
| 3 | # License: GNU LGPLv3 |
|---|
| 4 | # |
|---|
| 5 | # This file is part of Multi-Mechanize |
|---|
| 6 | # |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | import urllib2 |
|---|
| 10 | import time |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | class Transaction(object): |
|---|
| 15 | def __init__(self): |
|---|
| 16 | self.custom_timers = {} |
|---|
| 17 | |
|---|
| 18 | def run(self): |
|---|
| 19 | start_timer = time.time() |
|---|
| 20 | resp = urllib2.urlopen('http://www.example.com/') |
|---|
| 21 | content = resp.read() |
|---|
| 22 | latency = time.time() - start_timer |
|---|
| 23 | |
|---|
| 24 | self.custom_timers['Example_Homepage'] = latency |
|---|
| 25 | |
|---|
| 26 | assert (resp.code == 200), 'Bad HTTP Response' |
|---|
| 27 | assert ('Example Web Page' in content), 'Failed Content Verification' |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | if __name__ == '__main__': |
|---|
| 31 | trans = Transaction() |
|---|
| 32 | trans.run() |
|---|
| 33 | print trans.custom_timers |
|---|
Note: See
TracBrowser for help on using the repository browser.