Port test suite from nose to pytest.

This just eliminates all errors on the tests collection. Elimination of
failures is left to the next commit.
This commit is contained in:
Matěj Cepl 2020-10-06 07:54:49 +02:00
commit 77dc60ea97
146 changed files with 1172 additions and 1277 deletions

View file

@ -1,8 +1,7 @@
from __future__ import unicode_literals
# Ensure 'assert_raises' context manager support for Python 2.6
import tests.backport_assert_raises
from nose.tools import assert_raises
import pytest
import boto
import sure # noqa
@ -56,7 +55,7 @@ def test_key_pairs_empty():
def test_key_pairs_invalid_id():
conn = boto.connect_ec2("the_key", "the_secret")
with assert_raises(EC2ResponseError) as cm:
with pytest.raises(EC2ResponseError) as cm:
conn.get_all_key_pairs("foo")
cm.exception.code.should.equal("InvalidKeyPair.NotFound")
cm.exception.status.should.equal(400)
@ -67,7 +66,7 @@ def test_key_pairs_invalid_id():
def test_key_pairs_create():
conn = boto.connect_ec2("the_key", "the_secret")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
conn.create_key_pair("foo", dry_run=True)
ex.exception.error_code.should.equal("DryRunOperation")
ex.exception.status.should.equal(400)
@ -110,7 +109,7 @@ def test_key_pairs_create_exist():
conn.create_key_pair("foo")
assert len(conn.get_all_key_pairs()) == 1
with assert_raises(EC2ResponseError) as cm:
with pytest.raises(EC2ResponseError) as cm:
conn.create_key_pair("foo")
cm.exception.code.should.equal("InvalidKeyPair.Duplicate")
cm.exception.status.should.equal(400)
@ -130,7 +129,7 @@ def test_key_pairs_delete_exist():
conn = boto.connect_ec2("the_key", "the_secret")
conn.create_key_pair("foo")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
r = conn.delete_key_pair("foo", dry_run=True)
ex.exception.error_code.should.equal("DryRunOperation")
ex.exception.status.should.equal(400)
@ -147,7 +146,7 @@ def test_key_pairs_delete_exist():
def test_key_pairs_import():
conn = boto.connect_ec2("the_key", "the_secret")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
conn.import_key_pair("foo", RSA_PUBLIC_KEY_OPENSSH, dry_run=True)
ex.exception.error_code.should.equal("DryRunOperation")
ex.exception.status.should.equal(400)
@ -176,7 +175,7 @@ def test_key_pairs_import_exist():
assert kp.name == "foo"
assert len(conn.get_all_key_pairs()) == 1
with assert_raises(EC2ResponseError) as cm:
with pytest.raises(EC2ResponseError) as cm:
conn.create_key_pair("foo")
cm.exception.code.should.equal("InvalidKeyPair.Duplicate")
cm.exception.status.should.equal(400)
@ -187,19 +186,19 @@ def test_key_pairs_import_exist():
def test_key_pairs_invalid():
conn = boto.connect_ec2("the_key", "the_secret")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
conn.import_key_pair("foo", b"")
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
ex.exception.status.should.equal(400)
ex.exception.message.should.equal("Key is not in valid OpenSSH public key format")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
conn.import_key_pair("foo", b"garbage")
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
ex.exception.status.should.equal(400)
ex.exception.message.should.equal("Key is not in valid OpenSSH public key format")
with assert_raises(EC2ResponseError) as ex:
with pytest.raises(EC2ResponseError) as ex:
conn.import_key_pair("foo", DSA_PUBLIC_KEY_OPENSSH)
ex.exception.error_code.should.equal("InvalidKeyPair.Format")
ex.exception.status.should.equal(400)