Skip to content

Commit 014c4dc

Browse files
authored
change: upgrade pytest and other deps, tox clean-up (#1836)
1 parent f7d7148 commit 014c4dc

File tree

11 files changed

+35
-44
lines changed

11 files changed

+35
-44
lines changed

buildspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ phases:
1616

1717
- start_time=`date +%s`
1818
- |
19-
execute-command-if-has-matching-changes "env -u AWS_DEFAULT_REGION tox -e py38 -- tests/integ -m \"not local_mode\" -n 512 --reruns 3 --reruns-delay 5 --durations 50 --boto-config '{\"region_name\": \"us-east-2\"}'" "tests/integ" "tests/scripts" "tests/data" "tests/conftest.py" "tests/__init__.py" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"
19+
execute-command-if-has-matching-changes "env -u AWS_DEFAULT_REGION tox -e py38 -- tests/integ -m \"not local_mode and not cron\" -n 512 --reruns 3 --reruns-delay 5 --durations 50 --boto-config '{\"region_name\": \"us-east-2\"}'" "tests/integ" "tests/scripts" "tests/data" "tests/conftest.py" "tests/__init__.py" "src/*.py" "setup.py" "setup.cfg" "buildspec.yml"
2020
- ./ci-scripts/displaytime.sh 'py38 tests/integ' $start_time
2121

2222
post_build:

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,16 @@ def read_version():
5959
extras["test"] = (
6060
[
6161
extras["all"],
62-
"tox==3.15.1",
62+
"tox",
6363
"flake8",
64-
"pytest==4.6.10",
64+
"pytest",
6565
"pytest-cov",
6666
"pytest-rerunfailures",
6767
"pytest-xdist",
6868
"mock",
6969
"contextlib2",
7070
"awslogs",
71-
"black==19.10b0 ; python_version >= '3.6'",
71+
"black",
7272
"stopit==1.1.2",
7373
"apache-airflow==1.10.11",
7474
"fabric>=2.0",

tests/integ/test_git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def test_github_with_ssh_passphrase_not_configured(
222222

223223
with pytest.raises(subprocess.CalledProcessError) as error:
224224
sklearn.fit({"train": train_input, "test": test_input})
225-
assert "returned non-zero exit status" in str(error)
225+
assert "returned non-zero exit status" in str(error.value)
226226

227227

228228
@pytest.mark.local_mode

tests/unit/sagemaker/model/test_framework_model.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def test_git_support_git_clone_fail(sagemaker_session):
210210
sagemaker_session=sagemaker_session, entry_point=entry_point, git_config=git_config
211211
)
212212
model.prepare_container_def(instance_type=INSTANCE_TYPE)
213-
assert "returned non-zero exit status" in str(error)
213+
assert "returned non-zero exit status" in str(error.value)
214214

215215

216216
@patch(
@@ -227,7 +227,7 @@ def test_git_support_branch_not_exist(git_clone_repo, sagemaker_session):
227227
sagemaker_session=sagemaker_session, entry_point=entry_point, git_config=git_config
228228
)
229229
model.prepare_container_def(instance_type=INSTANCE_TYPE)
230-
assert "returned non-zero exit status" in str(error)
230+
assert "returned non-zero exit status" in str(error.value)
231231

232232

233233
@patch(
@@ -244,7 +244,7 @@ def test_git_support_commit_not_exist(git_clone_repo, sagemaker_session):
244244
sagemaker_session=sagemaker_session, entry_point=entry_point, git_config=git_config
245245
)
246246
model.prepare_container_def(instance_type=INSTANCE_TYPE)
247-
assert "returned non-zero exit status" in str(error)
247+
assert "returned non-zero exit status" in str(error.value)
248248

249249

250250
@patch(
@@ -391,7 +391,7 @@ def test_git_support_ssh_passphrase_required(tar_and_upload_dir, git_clone_repo,
391391
sagemaker_session=sagemaker_session, entry_point=entry_point, git_config=git_config
392392
)
393393
model.prepare_container_def(instance_type=INSTANCE_TYPE)
394-
assert "returned non-zero exit status" in str(error)
394+
assert "returned non-zero exit status" in str(error.value)
395395

396396

397397
@patch(
@@ -460,4 +460,4 @@ def test_git_support_codecommit_ssh_passphrase_required(
460460
sagemaker_session=sagemaker_session, entry_point=entry_point, git_config=git_config
461461
)
462462
model.prepare_container_def(instance_type=INSTANCE_TYPE)
463-
assert "returned non-zero exit status" in str(error)
463+
assert "returned non-zero exit status" in str(error.value)

tests/unit/sagemaker/tensorflow/test_estimator_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,4 @@ def test_require_image_uri_if_fw_ver_is_less_than_1_11(
138138
"make sure to pass them directly as hyperparameters instead."
139139
).format(version=tensorflow_training_version, region=REGION)
140140

141-
assert expected_msg in str(e)
141+
assert expected_msg in str(e.value)

tests/unit/test_estimator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ def test_git_support_git_clone_fail(sagemaker_session):
943943
)
944944
with pytest.raises(subprocess.CalledProcessError) as error:
945945
fw.fit()
946-
assert "returned non-zero exit status" in str(error)
946+
assert "returned non-zero exit status" in str(error.value)
947947

948948

949949
@patch(
@@ -964,7 +964,7 @@ def test_git_support_branch_not_exist(sagemaker_session):
964964
)
965965
with pytest.raises(subprocess.CalledProcessError) as error:
966966
fw.fit()
967-
assert "returned non-zero exit status" in str(error)
967+
assert "returned non-zero exit status" in str(error.value)
968968

969969

970970
@patch(
@@ -985,7 +985,7 @@ def test_git_support_commit_not_exist(sagemaker_session):
985985
)
986986
with pytest.raises(subprocess.CalledProcessError) as error:
987987
fw.fit()
988-
assert "returned non-zero exit status" in str(error)
988+
assert "returned non-zero exit status" in str(error.value)
989989

990990

991991
@patch(
@@ -1151,7 +1151,7 @@ def test_git_support_ssh_passphrase_required(git_clone_repo, sagemaker_session):
11511151
)
11521152
with pytest.raises(subprocess.CalledProcessError) as error:
11531153
fw.fit()
1154-
assert "returned non-zero exit status" in str(error)
1154+
assert "returned non-zero exit status" in str(error.value)
11551155

11561156

11571157
@patch(

tests/unit/test_fw_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,13 @@ def test_model_code_key_prefix_and_image_present(time):
456456
def test_model_code_key_prefix_with_prefix_present_and_others_none_fail():
457457
with pytest.raises(TypeError) as error:
458458
fw_utils.model_code_key_prefix("prefix", None, None)
459-
assert "expected string" in str(error)
459+
assert "expected string" in str(error.value)
460460

461461

462462
def test_model_code_key_prefix_with_all_none_fail():
463463
with pytest.raises(TypeError) as error:
464464
fw_utils.model_code_key_prefix(None, None, None)
465-
assert "expected string" in str(error)
465+
assert "expected string" in str(error.value)
466466

467467

468468
def test_region_supports_debugger_feature_returns_true_for_supported_regions():

tests/unit/test_git_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_git_clone_repo_clone_fail(mkdtemp, check_call):
9595
dependencies = ["foo", "bar"]
9696
with pytest.raises(subprocess.CalledProcessError) as error:
9797
git_utils.git_clone_repo(git_config, entry_point, source_dir, dependencies)
98-
assert "returned non-zero exit status" in str(error)
98+
assert "returned non-zero exit status" in str(error.value)
9999

100100

101101
@patch(
@@ -110,7 +110,7 @@ def test_git_clone_repo_branch_not_exist(mkdtemp, check_call):
110110
dependencies = ["foo", "bar"]
111111
with pytest.raises(subprocess.CalledProcessError) as error:
112112
git_utils.git_clone_repo(git_config, entry_point, source_dir, dependencies)
113-
assert "returned non-zero exit status" in str(error)
113+
assert "returned non-zero exit status" in str(error.value)
114114

115115

116116
@patch(
@@ -129,7 +129,7 @@ def test_git_clone_repo_commit_not_exist(mkdtemp, check_call):
129129
dependencies = ["foo", "bar"]
130130
with pytest.raises(subprocess.CalledProcessError) as error:
131131
git_utils.git_clone_repo(git_config, entry_point, source_dir, dependencies)
132-
assert "returned non-zero exit status" in str(error)
132+
assert "returned non-zero exit status" in str(error.value)
133133

134134

135135
@patch("subprocess.check_call")
@@ -358,7 +358,7 @@ def test_git_clone_repo_with_username_and_password_wrong_creds(mkdtemp, check_ca
358358
env["GIT_TERMINAL_PROMPT"] = "0"
359359
with pytest.raises(subprocess.CalledProcessError) as error:
360360
git_utils.git_clone_repo(git_config=git_config, entry_point=entry_point)
361-
assert "returned non-zero exit status" in str(error)
361+
assert "returned non-zero exit status" in str(error.value)
362362

363363

364364
@patch(
@@ -381,7 +381,7 @@ def test_git_clone_repo_with_token_wrong_creds(mkdtemp, check_call):
381381
env["GIT_TERMINAL_PROMPT"] = "0"
382382
with pytest.raises(subprocess.CalledProcessError) as error:
383383
git_utils.git_clone_repo(git_config=git_config, entry_point=entry_point)
384-
assert "returned non-zero exit status" in str(error)
384+
assert "returned non-zero exit status" in str(error.value)
385385

386386

387387
@patch(
@@ -404,7 +404,7 @@ def test_git_clone_repo_with_and_token_2fa_wrong_creds(mkdtemp, check_call):
404404
env["GIT_TERMINAL_PROMPT"] = "0"
405405
with pytest.raises(subprocess.CalledProcessError) as error:
406406
git_utils.git_clone_repo(git_config=git_config, entry_point=entry_point)
407-
assert "returned non-zero exit status" in str(error)
407+
assert "returned non-zero exit status" in str(error.value)
408408

409409

410410
@patch("subprocess.check_call")
@@ -448,7 +448,7 @@ def test_git_clone_repo_codecommit_ssh_passphrase_required(mkdtemp, check_call):
448448
entry_point = "entry_point"
449449
with pytest.raises(subprocess.CalledProcessError) as error:
450450
git_utils.git_clone_repo(git_config, entry_point)
451-
assert "returned non-zero exit status" in str(error)
451+
assert "returned non-zero exit status" in str(error.value)
452452

453453

454454
@patch(
@@ -463,4 +463,4 @@ def test_git_clone_repo_codecommit_https_creds_not_stored_locally(mkdtemp, check
463463
entry_point = "entry_point"
464464
with pytest.raises(subprocess.CalledProcessError) as error:
465465
git_utils.git_clone_repo(git_config, entry_point)
466-
assert "returned non-zero exit status" in str(error)
466+
assert "returned non-zero exit status" in str(error.value)

tests/unit/test_multidatamodel.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ def test_multi_data_model_create_with_invalid_model_data_prefix():
120120
MultiDataModel(
121121
name=MODEL_NAME, model_data_prefix=invalid_model_data_prefix, image_uri=IMAGE, role=ROLE
122122
)
123-
err_msg = 'ValueError: Expecting S3 model prefix beginning with "s3://". Received: "{}"'.format(
123+
err_msg = 'Expecting S3 model prefix beginning with "s3://". Received: "{}"'.format(
124124
invalid_model_data_prefix
125125
)
126-
assert err_msg in str(ex)
126+
assert err_msg in str(ex.value)
127127

128128

129129
def test_multi_data_model_create_with_invalid_arguments(sagemaker_session, mxnet_model):
@@ -309,11 +309,9 @@ def test_add_model_with_invalid_model_uri(multi_data_model):
309309
with pytest.raises(ValueError) as ex:
310310
multi_data_model.add_model(INVALID_S3_URL)
311311

312-
assert 'ValueError: model_source must either be a valid local file path or s3 uri. Received: "{}"'.format(
312+
assert 'model_source must either be a valid local file path or s3 uri. Received: "{}"'.format(
313313
INVALID_S3_URL
314-
) in str(
315-
ex
316-
)
314+
) in str(ex.value)
317315

318316

319317
def test_list_models(multi_data_model):

tests/unit/test_session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_get_execution_role_throws_exception_if_arn_is_not_role():
286286

287287
with pytest.raises(ValueError) as error:
288288
get_execution_role(session)
289-
assert "ValueError: The current AWS identity is not a role" in str(error)
289+
assert "The current AWS identity is not a role" in str(error.value)
290290

291291

292292
def test_get_execution_role_throws_exception_if_arn_is_not_role_with_role_in_name():
@@ -295,7 +295,7 @@ def test_get_execution_role_throws_exception_if_arn_is_not_role_with_role_in_nam
295295

296296
with pytest.raises(ValueError) as error:
297297
get_execution_role(session)
298-
assert "ValueError: The current AWS identity is not a role" in str(error)
298+
assert "The current AWS identity is not a role" in str(error.value)
299299

300300

301301
@patch("six.moves.builtins.open", mock_open(read_data='{"ResourceName": "SageMakerInstance"}'))

0 commit comments

Comments
 (0)