From e40447cc845aeb616d413fd93dcd4a5704f4c90d Mon Sep 17 00:00:00 2001 From: yh Date: Wed, 5 Jun 2019 18:21:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2travis=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=9D=9E=20test=E4=B9=8B=E5=A4=96=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- test/core/test_callbacks.py | 4 +++- test/core/test_utils.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) 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()