diff --git a/.travis.yml b/.travis.yml index 559fc86e..210d158a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ install: - pip install pytest-cov # command to run tests script: - - pytest --cov=./ + - pytest --cov=./ test/ after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/test/core/test_callbacks.py b/test/core/test_callbacks.py index db640eb1..e2aa5fa4 100644 --- a/test/core/test_callbacks.py +++ b/test/core/test_callbacks.py @@ -12,6 +12,7 @@ from fastNLP import AccuracyMetric from fastNLP import SGD from fastNLP import Trainer from fastNLP.models.base_model import NaiveClassifier +from fastNLP.core.callback import EarlyStopError def prepare_env(): @@ -65,7 +66,8 @@ class TestCallback(unittest.TestCase): dev_data=data_set, metrics=AccuracyMetric(pred="predict", target="y"), callbacks=[EarlyStopCallback(5)]) - trainer.train() + with self.assertRaises(EarlyStopError): + trainer.train() def test_lr_scheduler(self): data_set, model = prepare_env() diff --git a/test/core/test_utils.py b/test/core/test_utils.py index 91b5d00f..e3e019c6 100644 --- a/test/core/test_utils.py +++ b/test/core/test_utils.py @@ -18,7 +18,7 @@ class Model(nn.Module): self.param = nn.Parameter(torch.zeros(0)) -class TestMoveModelDeivce(unittest.TestCase): +class TestMoveModelDevice(unittest.TestCase): def test_case1(self): # 测试str model = Model()