You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_set_backend.py 549 B

123456789101112131415161718
  1. import os
  2. import pytest
  3. from fastNLP.envs.set_backend import dump_fastnlp_backend
  4. from tests.helpers.utils import Capturing
  5. from fastNLP.core import rank_zero_rm
  6. def test_dump_fastnlp_envs():
  7. filepath = None
  8. try:
  9. with Capturing() as output:
  10. dump_fastnlp_backend(backend="torch")
  11. filepath = os.path.join(os.path.expanduser('~'), '.fastNLP', 'envs', os.environ['CONDA_DEFAULT_ENV']+'.json')
  12. assert filepath in output[0]
  13. assert os.path.exists(filepath)
  14. finally:
  15. rank_zero_rm(filepath)