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

@ -2,7 +2,7 @@ from __future__ import unicode_literals
import sure # noqa
import re
from nose.tools import assert_raises
import pytest
import boto3
from botocore.client import ClientError
@ -32,7 +32,7 @@ def test_create_database_already_exists():
database_name = "cantcreatethisdatabasetwice"
helpers.create_database(client, database_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.create_database(client, database_name)
exc.exception.response["Error"]["Code"].should.equal("AlreadyExistsException")
@ -43,7 +43,7 @@ def test_get_database_not_exits():
client = boto3.client("glue", region_name="us-east-1")
database_name = "nosuchdatabase"
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_database(client, database_name)
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -102,7 +102,7 @@ def test_create_table_already_exists():
table_name = "cantcreatethistabletwice"
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.create_table(client, database_name, table_name)
exc.exception.response["Error"]["Code"].should.equal("AlreadyExistsException")
@ -192,7 +192,7 @@ def test_get_table_version_not_found():
helpers.create_database(client, database_name)
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table_version(client, database_name, "myfirsttable", "20")
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -207,7 +207,7 @@ def test_get_table_version_invalid_input():
helpers.create_database(client, database_name)
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table_version(client, database_name, "myfirsttable", "10not-an-int")
exc.exception.response["Error"]["Code"].should.equal("InvalidInputException")
@ -219,7 +219,7 @@ def test_get_table_not_exits():
database_name = "myspecialdatabase"
helpers.create_database(client, database_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table(client, database_name, "myfirsttable")
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -233,7 +233,7 @@ def test_get_table_when_database_not_exits():
client = boto3.client("glue", region_name="us-east-1")
database_name = "nosuchdatabase"
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table(client, database_name, "myfirsttable")
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -256,7 +256,7 @@ def test_delete_table():
result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
# confirm table is deleted
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table(client, database_name, table_name)
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -281,7 +281,7 @@ def test_batch_delete_table():
result["ResponseMetadata"]["HTTPStatusCode"].should.equal(200)
# confirm table is deleted
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_table(client, database_name, table_name)
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -350,7 +350,7 @@ def test_create_partition_already_exist():
helpers.create_partition(client, database_name, table_name, values=values)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.create_partition(client, database_name, table_name, values=values)
exc.exception.response["Error"]["Code"].should.equal("AlreadyExistsException")
@ -366,7 +366,7 @@ def test_get_partition_not_found():
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_partition(client, database_name, table_name, values)
exc.exception.response["Error"]["Code"].should.equal("EntityNotFoundException")
@ -542,7 +542,7 @@ def test_update_partition_not_found_moving():
helpers.create_database(client, database_name)
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.update_partition(
client,
database_name,
@ -565,7 +565,7 @@ def test_update_partition_not_found_change_in_place():
helpers.create_database(client, database_name)
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.update_partition(
client, database_name, table_name, old_values=values, values=values
)
@ -588,7 +588,7 @@ def test_update_partition_cannot_overwrite():
helpers.create_partition(client, database_name, table_name, values=values[0])
helpers.create_partition(client, database_name, table_name, values=values[1])
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.update_partition(
client, database_name, table_name, old_values=values[0], values=values[1]
)
@ -648,7 +648,7 @@ def test_update_partition_move():
columns=[{"Name": "country", "Type": "string"}],
)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
helpers.get_partition(client, database_name, table_name, values)
# Old partition shouldn't exist anymore
@ -697,7 +697,7 @@ def test_delete_partition_bad_partition():
helpers.create_database(client, database_name)
helpers.create_table(client, database_name, table_name)
with assert_raises(ClientError) as exc:
with pytest.raises(ClientError) as exc:
client.delete_partition(
DatabaseName=database_name, TableName=table_name, PartitionValues=values
)