Repository: gabrielfalcao/HTTPretty

Issue:
httpretty crashes if program uses unix sockets
```
        def connect(self, address):
            self._address = (self._host, self._port) = address
```
Crashes with `too many values to unpack` because unix socket addresses are just files. Working on a PR.

Discussion:

Patch:
diff --git a/httpretty/core.py b/httpretty/core.py
index 25926a0..a1b2469 100644
--- a/httpretty/core.py
+++ b/httpretty/core.py
@@ -290,9 +290,18 @@ class fakesock(object):
             self.type = type
 
         def connect(self, address):
-            self._address = (self._host, self._port) = address
             self._closed = False
-            self.is_http = self._port in POTENTIAL_HTTP_PORTS | POTENTIAL_HTTPS_PORTS
+
+            try:
+                self._address = (self._host, self._port) = address
+            except ValueError:
+                # We get here when the address is just a string pointing to a
+                # unix socket path/file
+                #
+                # See issue #206
+                self.is_http = False
+            else:
+                self.is_http = self._port in POTENTIAL_HTTP_PORTS | POTENTIAL_HTTPS_PORTS
 
             if not self.is_http:
                 if self.truesock:


Test patch:
diff --git a/tests/unit/test_httpretty.py b/tests/unit/test_httpretty.py
index d26caf4..3059c12 100644
--- a/tests/unit/test_httpretty.py
+++ b/tests/unit/test_httpretty.py
@@ -353,6 +353,18 @@ def test_fake_socket_passes_through_shutdown():
     expect(s.shutdown).called_with(socket.SHUT_RD).should_not.throw(AttributeError)
     s.truesock.shutdown.assert_called_with(socket.SHUT_RD)
 
+def test_unix_socket():
+    import socket
+    HTTPretty.enable()
+
+    # Create a UDS socket
+    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+    server_address = './not-exist-socket'
+    try:
+        sock.connect(server_address)
+    except socket.error:
+        # We expect this, since the server_address does not exist
+        pass
 
 def test_HTTPrettyRequest_json_body():
     """ A content-type of application/json should parse a valid json body """