Skip to content

Commit 330e1f3

Browse files
Improved local test example with mock
1 parent 505f364 commit 330e1f3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_local.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def test_local_training():
2525
f"""
2626
Compare with https://github.com/aws/amazon-sagemaker-examples/tree/main/advanced_functionality/scikit_bring_your_own/container/local_test .
2727
"""
28-
assert training_environment.SAGEMAKER_BASE_PATH == "/opt/ml"
29-
assert training_environment.base_dir.endswith("/opt_ml")
28+
assert training_environment.SAGEMAKER_BASE_PATH == "/opt/ml", "default path should be /opt/ml"
29+
assert training_environment.base_dir.endswith("/opt_ml"), "override path should end with /opt_ml"
3030

3131
test_util._clean_training_opt_ml_dir()
3232
distutils.dir_util.copy_tree("./source_dir/training_clean/", "./opt_ml/code/")
@@ -44,7 +44,7 @@ def test_local_training():
4444
logging.info("Finished training")
4545

4646

47-
@mock.patch.dict(os.environ, {"SM_MODEL_DIR": "./opt_ml/model"})
47+
@mock.patch.dict(os.environ, {"SM_MODEL_DIR": os.path.join(os.path.dirname(__file__), "opt_ml/model")})
4848
def test_local_training_with_coverage():
4949
# import will start training
5050
from source_dir.training_clean import train_clean

0 commit comments

Comments
 (0)