From e9bc2bf4a681d9bec144ff52e37e9b46c9c82e6a Mon Sep 17 00:00:00 2001 From: x54-729 <17307130121@fudan.edu.cn> Date: Wed, 18 May 2022 06:48:25 +0000 Subject: [PATCH] =?UTF-8?q?1.=20=E4=B8=BAtest=5Fpaddle=5Futils=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0paddle=E6=A0=87=E7=AD=BE=EF=BC=9B2.=E4=BF=AE=E6=94=B9t?= =?UTF-8?q?est=5Fset=5Fbackend=E6=B5=8B=E8=AF=95=E4=BE=8B=E9=80=82?= =?UTF-8?q?=E5=BA=94=E6=B2=A1=E6=9C=89conda=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/core/utils/test_paddle_utils.py | 1 + tests/envs/test_set_backend.py | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/core/utils/test_paddle_utils.py b/tests/core/utils/test_paddle_utils.py index ecabc1df..d0c4c972 100644 --- a/tests/core/utils/test_paddle_utils.py +++ b/tests/core/utils/test_paddle_utils.py @@ -64,6 +64,7 @@ class TestPaddleToDevice: # ############################################################################ +@pytest.mark.paddle class TestPaddleMoveDataToDevice: def check_gpu(self, tensor, idx): diff --git a/tests/envs/test_set_backend.py b/tests/envs/test_set_backend.py index c45acd7b..a283272c 100644 --- a/tests/envs/test_set_backend.py +++ b/tests/envs/test_set_backend.py @@ -9,10 +9,14 @@ from fastNLP.envs.distributed import rank_zero_rm def test_dump_fastnlp_envs(): filepath = None try: - with Capturing() as output: - dump_fastnlp_backend(backend="torch") - filepath = os.path.join(os.path.expanduser('~'), '.fastNLP', 'envs', os.environ['CONDA_DEFAULT_ENV']+'.json') - assert filepath in output[0] - assert os.path.exists(filepath) + if 'CONDA_DEFAULT_ENV' in os.environ: + with Capturing() as output: + dump_fastnlp_backend(backend="torch") + filepath = os.path.join(os.path.expanduser('~'), '.fastNLP', 'envs', os.environ['CONDA_DEFAULT_ENV']+'.json') + assert filepath in output[0] + assert os.path.exists(filepath) + else: + with pytest.raises(RuntimeError): + dump_fastnlp_backend(backend="torch") finally: rank_zero_rm(filepath)