diff options
| author | Gabriel Falcao <gabriel@nacaolivre.org> | 2013-02-14 12:32:44 -0500 |
|---|---|---|
| committer | Gabriel Falcao <gabriel@nacaolivre.org> | 2013-02-14 12:32:44 -0500 |
| commit | 2eb529d8d9fe237a946b8ecdf769555324fdd6ff (patch) | |
| tree | 7dd895fe186ea9ebd084a5f697b81f41831a6ca2 /httpretty | |
| parent | 50ec5d6d1a4148a1eb7f8d50ef06b81f6e377564 (diff) | |
| download | httpretty-2eb529d8d9fe237a946b8ecdf769555324fdd6ff.tar.gz | |
raising a RuntimeError when unexpected socket methods are called,
that will leverage openning issues more easily. refs #29
Diffstat (limited to 'httpretty')
| -rw-r--r-- | httpretty/__init__.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/httpretty/__init__.py b/httpretty/__init__.py index 45da83c..dfb0c3c 100644 --- a/httpretty/__init__.py +++ b/httpretty/__init__.py @@ -23,9 +23,10 @@ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -version = '0.5.6' +version = '0.5.7' import re +import inspect import socket import functools import itertools @@ -38,7 +39,7 @@ import types PY3 = sys.version_info[0] == 3 if PY3: text_type = str - binary_type = bytes + byte_type = bytes import io StringIO = io.StringIO @@ -47,7 +48,7 @@ if PY3: return self.__str__() else: text_type = unicode - binary_type = str + byte_type = str import StringIO StringIO = StringIO.StringIO @@ -101,7 +102,7 @@ def utf8(s): if isinstance(s, text_type): s = s.encode('utf-8') - return binary_type(s) + return byte_type(s) def parse_requestline(s): @@ -306,7 +307,17 @@ class fakesock(object): self._entry = entry def debug(*a, **kw): - import debug + frame = inspect.stack()[0][0] + lines = map(utf8, traceback.format_stack(frame)) + + message = [ + "HTTPretty intercepted and unexpected socket method call.", + ("Please open an issue at " + "'https://github.com/gabrielfalcao/HTTPretty/issues'"), + "And paste the following traceback:\n", + "".join(lines), + ] + raise RuntimeError("\n".join(message)) def settimeout(self, new_timeout): self.timeout = new_timeout |
