diff --git a/Makefile b/Makefile index 05890c7..14fe419 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ test: rm -f .coverage nosetests --rednose --exe --cover-package=s3po --with-coverage --cover-branches --logging-clear-handlers -v +test3: + rm -f .coverage + python3 -m nose --rednose --exe --cover-package=s3po --with-coverage --cover-branches --logging-clear-handlers -v + clean: # Remove the build rm -rf build dist diff --git a/README.md b/README.md index 07c67d2..478892d 100644 --- a/README.md +++ b/README.md @@ -140,4 +140,5 @@ vagrant ssh # On the vagrant instance make test +make test3 # To run the tests under Python 3 ``` diff --git a/s3po/backends/memory.py b/s3po/backends/memory.py index addb738..30be0eb 100644 --- a/s3po/backends/memory.py +++ b/s3po/backends/memory.py @@ -14,6 +14,13 @@ def __init__(self): def download(self, bucket, key, fobj, retries, headers=None): '''Download the contents of bucket/key to fobj''' obj = self.buckets[bucket].get(key) + + # if we stored a bytes object, decode it into a string + try: + obj = obj.decode('ascii') + except AttributeError: + pass + if not obj: raise DownloadException('%s / %s not found' % (bucket, key)) else: diff --git a/s3po/connection.py b/s3po/connection.py index bcac39e..fcca10f 100644 --- a/s3po/connection.py +++ b/s3po/connection.py @@ -66,7 +66,7 @@ def upload_file(self, bucket, key, path, headers=None, extra=None, retries=3): '''Upload the file at path to bucket/key. This method is important for use in batch mode, so that the file object can be used with the right context management''' - with open(os.path.abspath(path)) as fobj: + with open(os.path.abspath(path), 'rb') as fobj: return self.upload( bucket, key, fobj, headers=headers, extra=extra, retries=retries) diff --git a/scripts/vagrant/provision.sh b/scripts/vagrant/provision.sh index 360fbb4..9f6449c 100755 --- a/scripts/vagrant/provision.sh +++ b/scripts/vagrant/provision.sh @@ -2,7 +2,8 @@ set -e -sudo apt-get install -y python-pip python-dev +sudo apt-get update +sudo apt-get install -y python-pip python-dev python3-pip python3-dev echo '[Credentials] aws_access_key_id = not-a-real-id @@ -11,6 +12,7 @@ aws_secret_access_key = not-a-real-key' > ~/.boto ( cd /vagrant sudo pip install -r requirements.txt + sudo pip3 install -r requirements.txt ) echo $'\ncd /vagrant' >> ~/.profile