Support Python 3 using six

This commit is contained in:
David Baumgold 2014-08-26 13:25:50 -04:00
commit eedb4c4b73
67 changed files with 455 additions and 255 deletions

View file

@ -2,6 +2,8 @@ from __future__ import unicode_literals
import boto
from boto.exception import EC2ResponseError
import sure # noqa
import tests.backport_assert_raises
from nose.tools import assert_raises
from moto import mock_ec2
@ -23,18 +25,21 @@ def test_basic_decorator():
def test_context_manager():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.get_all_instances.when.called_with().should.throw(EC2ResponseError)
with assert_raises(EC2ResponseError):
conn.get_all_instances()
with mock_ec2():
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
conn.get_all_instances.when.called_with().should.throw(EC2ResponseError)
with assert_raises(EC2ResponseError):
conn.get_all_instances()
def test_decorator_start_and_stop():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.get_all_instances.when.called_with().should.throw(EC2ResponseError)
with assert_raises(EC2ResponseError):
conn.get_all_instances()
mock = mock_ec2()
mock.start()
@ -42,7 +47,8 @@ def test_decorator_start_and_stop():
list(conn.get_all_instances()).should.equal([])
mock.stop()
conn.get_all_instances.when.called_with().should.throw(EC2ResponseError)
with assert_raises(EC2ResponseError):
conn.get_all_instances()
@mock_ec2

View file

@ -7,7 +7,7 @@ from moto import mock_ec2
@mock_ec2
def test_latest_meta_data():
res = requests.get("http://169.254.169.254/latest/meta-data/")
res.content.should.equal("iam")
res.content.should.equal(b"iam")
@mock_ec2
@ -24,7 +24,7 @@ def test_meta_data_iam():
@mock_ec2
def test_meta_data_security_credentials():
res = requests.get("http://169.254.169.254/latest/meta-data/iam/security-credentials/")
res.content.should.equal("default-role")
res.content.should.equal(b"default-role")
@mock_ec2

View file

@ -33,7 +33,8 @@ def test_port_argument(run_simple):
def test_domain_dispatched():
dispatcher = DomainDispatcherApplication(create_backend_app)
backend_app = dispatcher.get_application("email.us-east1.amazonaws.com")
backend_app.view_functions.keys()[0].should.equal('EmailResponse.dispatch')
keys = list(backend_app.view_functions.keys())
keys[0].should.equal('EmailResponse.dispatch')
def test_domain_without_matches():
@ -45,4 +46,5 @@ def test_domain_dispatched_with_service():
# If we pass a particular service, always return that.
dispatcher = DomainDispatcherApplication(create_backend_app, service="s3")
backend_app = dispatcher.get_application("s3.us-east1.amazonaws.com")
backend_app.view_functions.keys()[0].should.equal('ResponseObject.key_response')
keys = set(backend_app.view_functions.keys())
keys.should.contain('ResponseObject.key_response')