summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Falcao <gabriel@nacaolivre.org>2011-06-28 17:08:52 -0400
committerGabriel Falcao <gabriel@nacaolivre.org>2011-06-28 17:08:52 -0400
commite70bc73defdf8756c46f8eeade2124301955ee32 (patch)
tree18868b79d44ae8644e9b904d39dc413f565fae0a
parent02eeb42fd98dfcf847edae67af05246ba9c1e454 (diff)
downloadhttpretty-e70bc73defdf8756c46f8eeade2124301955ee32.tar.gz
improving the readme
-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