osxphotos/tests/locale_util.py
dvdkon ca3da647f2
Port to non-MacOS platforms (#1026)
* Port to non-MacOS platforms

* Keep NFD normalization on macOS

* Update locale_util.py

Fix lint error from ruff (runs in CI)

* Update query.py

click.Option first arg needs to be a list (different than click.option)

* Dynamically normalize Unicode paths in test

* Fix missing import

---------

Co-authored-by: Rhet Turnbull <rturnbull@gmail.com>
2023-05-07 06:55:56 -07:00

17 lines
391 B
Python

""" Helpers for running locale-dependent tests """
import contextlib
import locale
import pytest
def setlocale(typ, name):
try:
with contextlib.suppress(Exception):
locale.setlocale(typ, name)
# On Linux UTF-8 locales are separate
locale.setlocale(typ, f"{name}.UTF-8")
except locale.Error:
pytest.skip(f"Locale {name} not available")