summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md35
1 files changed, 20 insertions, 15 deletions
diff --git a/README.md b/README.md
index 8913a49..39922bd 100644
--- a/README.md
+++ b/README.md
@@ -35,33 +35,38 @@ HTTPretty will mock the response for you :) *(and also give you the latest reque
```python
from httpretty import HTTPretty
-HTTPretty.enable() # enable HTTPretty so that it will monkey patch the socket module
-HTTPretty.register_uri(HTTPretty.GET, "http://globo.com/",
- body="The biggest portal in Brazil")
+def test_one():
+ HTTPretty.enable() # enable HTTPretty so that it will monkey patch the socket module
+ HTTPretty.register_uri(HTTPretty.GET, "http://globo.com/",
+ body="The biggest portal in Brazil")
-fd = urllib2.urlopen('http://globo.com')
-got = fd.read()
-fd.close()
-
-print got
+ fd = urllib2.urlopen('http://globo.com')
+ got = fd.read()
+ fd.close()
-HTTPretty.disable() # disable afterwards, so that you will have no problems in coda that uses that socket module
+ assert got == "The biggest portal in Brazil"
+ HTTPretty.disable() # disable afterwards, so that you will have no problems in coda that uses that socket module
```
-**:: output ::**
-
- The biggest portal in Brazil
-
-
## ohhhh, really? can that be easier?
**YES** we've got a decorator
```python
+from httpretty import HTTPretty, httprettified
-```
+@httprettified
+def test_one():
+ HTTPretty.register_uri(HTTPretty.GET, "http://globo.com/",
+ body="The biggest portal in Brazil")
+ fd = urllib2.urlopen('http://globo.com')
+ got = fd.read()
+ fd.close()
+
+ assert got == "The biggest portal in Brazil"
+```
## mocking the status code