test_setlocale.py 585 B

123456789101112131415161718192021
  1. import locale
  2. import pytest
  3. from freesurfer_surface import setlocale, UnsupportedLocaleSettingError
  4. def test_set():
  5. system_locale = locale.setlocale(locale.LC_ALL)
  6. assert system_locale != 'C'
  7. with setlocale('C'):
  8. assert locale.setlocale(locale.LC_ALL) == 'C'
  9. assert locale.setlocale(locale.LC_ALL) == system_locale
  10. def test_invalid():
  11. system_locale = locale.setlocale(locale.LC_ALL)
  12. with pytest.raises(UnsupportedLocaleSettingError):
  13. with setlocale('abcdef21'):
  14. pass
  15. assert locale.setlocale(locale.LC_ALL) == system_locale