Skip to content

Commit

Permalink
Update READMEs with allow_net_connect documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitrodist committed May 27, 2015
1 parent 10cbee3 commit b5c301f
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
16 changes: 16 additions & 0 deletions README.md
Expand Up @@ -421,6 +421,22 @@ httpretty.disable()
httpretty.is_enabled().should.be.false

```

## raising an error if an unregistered endpoint is requested

```python
import urllib2
import httpretty

httpretty.enable()
httpretty.HTTPretty.allow_net_connect = False

httpretty.register_uri(httpretty.GET, 'http://www.google.com', body='OK')

urllib2.urlopen('http://www.google.com')
urllib2.urlopen('http://www.reddit.com') # raises httpretty.errors.UnmockedError
```

# Motivation

When building systems that access external resources such as RESTful
Expand Down
15 changes: 15 additions & 0 deletions README.rst
Expand Up @@ -418,6 +418,21 @@ checking if is enabled
httpretty.disable()
httpretty.is_enabled().should.be.false
raising an error if an unregistered endpoint is requested
---------------------------------------------------------

.. code:: python
import urllib2
import httpretty
httpretty.enable()
httpretty.HTTPretty.allow_net_connect = False
httpretty.register_uri(httpretty.GET, 'http://www.google.com', body='OK')
urllib2.urlopen('http://www.google.com')
urllib2.urlopen('http://www.reddit.com') # raises httpretty.errors.UnmockedError
Motivation
==========

Expand Down
15 changes: 15 additions & 0 deletions docs/docs.md
Expand Up @@ -325,3 +325,18 @@ httpretty.disable()
httpretty.is_enabled().should.be.false

```

## raising an error if an unregistered endpoint is requested

```python
import urllib2
import httpretty

httpretty.enable()
httpretty.HTTPretty.allow_net_connect = False

httpretty.register_uri(httpretty.GET, 'http://www.google.com', body='OK')

urllib2.urlopen('http://www.google.com')
urllib2.urlopen('http://www.reddit.com') # raises httpretty.errors.UnmockedError
```

0 comments on commit b5c301f

Please sign in to comment.