Decode HTTP responses, fixes bug #1282861

By default, the HTTPConnection class expose the raw.read urllib3
function which doesn't do any decoding on the http response.
We can fix this by passing decode_content=True to raw.read().

Change-Id: I7d42d31ae516705d1bde2769e642931308116c7a
Python 3: cast map() result to list

On Python 3, map() returns a generator, not a list. Cast explicitly the result
of map() to a list to get a list on Python 2 and Python 3.

The cast is useless in Python 2, but it doesn't hurt performances: it's just a
unit test.

Change-Id: I87486b7dbc42507a6fd7886748a2e09735b6fc5b
Python 3: Fix tests using temporary text files

Use mode "w" instead of the default mode "wb+" to get text file instead of
binary file on Python 3.

Change-Id: I2efe8d926309cfcd5ffe4ea963c11799773def73
Make bin/swift testable part 1

To make bin/swift importable for testing it needs to be renamed/moved.
The final idea is to move it to swiftclient/shell.py and add only a stub
in bin/swift to import swiftclient/shell.py.

However, doing this in a single step makes reviewing very hard, because
now there are > 1400 lines deleted from bin/swift and added to
swiftclient/shell.py - Gerrit doesn't detect the moved file.

For example: https://review.openstack.org/#/c/73710/2/

This patch first moves the code to swiftclient/shell.py and uses
setup.py/cfg to create the stub file in bin/swift. A follow up
(https://review.openstack.org/#/c/76489/) will then add the stub itself
in bin/swift (and remove the entry in setup.py).

The change to tox.ini is related to bug 1290562 and can be removed in
the future.

Change-Id: Id86392ccaf09e1d80a5d808fb49827d6d18c2588
Make bin/swift testable part 2

Follow up for patch https://review.openstack.org/#/c/76487/

Change-Id: I6801b75cb78a3da0631ca8a60b7c2756b8930e72
Python 3: Replace iter.next() with six.next(iter)

Use six.next() to be Python 3 compatible.

Change-Id: Ia16148a759d368872787d5896a7b1dc42ffcdfb5
Replace dict.iteritems() with dict.items()

dict.iteritems() has been removed in Python 3. In Python 2, dict.items()
creates a temporary list, but Samuel Merritt wrote:

"The size of the data is small enough that we don't need to worry about the
memory consumption; it's all just HTTP headers."

Change-Id: Iac427b8bbd032e4a1efb2bdc84a3968217eb6ddf
Python 3: Add six dependency

Change-Id: I350eb089e02b4c33cf34c9fdb65289a2ad77f9c9
Merge "Python 3: Replace iter.next() with six.next(iter)"
Merge "Python 3: Fix tests using temporary text files"
Merge "Python 3: cast map() result to list"
Merge "Python 3: Add six dependency"
Python 3: Fix module names in import

Use six.moves to fix imports on Python 3.

Change-Id: I35b9405690e9f0607b24d79aa7c00830df954c41
Python 3: Get compatible types from six

* Replace unicode with six.text_type
* Replace basestring with six.string_types
* The long type doesn't exist in Python 3 anymore: replace 1L with long(1) and
  only test this type with Python 2
* Fix quote(): quote the URL if the string is a byte string. Use "bytes" type
  instead of "str" to be Python 3 compatible.

Change-Id: I1df5aa85e4e7d07191fb5c654d52fc4bd8b9f440
set user-agent header

Change-Id: Ia67807667b4b5177d83cce9fcf16d98dc5024fbc
don't use mutable defaults in kwargs

Change-Id: I3ae71259ccc49a5d8a852388784c3dfd577df50a
Merge "Python 3: Get compatible types from six"
Removed usage of tuple unpacking in parameters.

Replaced it with traditional tuple unpacking. Needed for Python 3 support.

Change-Id: I714f32859f9b1ec7216eae777ea8968b5826af3b
Replaced print statements with print function.

This is needed for Python3 compatibility.

Change-Id: Iadd21e4b3a936b601a69f1db2aba8e1597f13fc3
Use the standard library's copy of mock when it's available.

Change-Id: Id6a31157582efe47cc3a74e6658679c2bec14767