test_setlocale.py 807 B

1234567891011121314151617181920212223242526272829
  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_unsupported():
  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
  16. def test_other_error():
  17. system_locale = locale.setlocale(locale.LC_ALL)
  18. with pytest.raises(TypeError):
  19. with setlocale(42):
  20. pass
  21. assert locale.setlocale(locale.LC_ALL) == system_locale