ansys / ansys/pyansys-tools-variableinterop

Tests do not run cleanly out of the box

Open
#118 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### 🔍 Before submitting the issue

- [X] I have searched among the existing issues
- [X] I am using a Python virtual environment

### 🐞 Description of the bug

If you follow the instructions in [README.rst](https://github.com/pyansys/ansys-common-variableinterop/blob/main/README.rst) to create a local development environment and run pytest, you will get 47 failed tests due to errors like:

```shell
src/ansys/common/variableinterop/array_values.py:118: in to_display_string
api_string: str = ArrayToFromStringUtil.value_to_string(
src/ansys/common/variableinterop/utils/array_to_from_string_util.py:58: in value_to_string
api_string += ",".join(map(stringify_action, np.nditer(value, flags=["refs_ok"])))
src/ansys/common/variableinterop/array_values.py:119: in
self, lambda elem: BooleanValue(elem.tolist()).to_display_string(locale_name)
src/ansys/common/variableinterop/scalar_values.py:313: in to_display_string
result: np.str_ = LocaleUtils.perform_safe_locale_action(
src/ansys/common/variableinterop/utils/locale_utils.py:26: in perform_safe_locale_action
locale.setlocale(locale.LC_ALL, locale_name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

category = 6, locale = 'de_DE.UTF-8'

def setlocale(category, locale=None):

""" Set the locale for the given category. The locale can be
a string, an iterable of two strings (language code and encoding),
or None.

Iterables are converted to strings using the locale aliasing
engine. Locale strings are passed directly to the C lib.

category may be given as one of the LC_* values.

"""
if locale and not isinstance(locale, _builtin_str):
# convert to string
locale = normalize(_build_localename(locale))
> return _setlocale(category, locale)
E locale.Error: unsupported locale setting

/usr/lib/python3.8/locale.py:608: Error
```

I found the fix is to install a specific locale (command can be found in [CI script](https://github.com/pyansys/ansys-common-variableinterop/blob/40a6fe69c2cfe54d4ec3f88d952da3d30e4b5c2f/.github/workflows/ci_cd.yml#L68)):

```shell
(.venv) nsharp@ubuntu:~/ver/ansys-common-variableinterop$ sudo locale-gen de_DE.UTF-8
[sudo] password for nsharp:
Generating locales (this might take a while)...
de_DE.UTF-8... done
Generation complete.
```

### 📝 Steps to reproduce

Follow README.rst to setup an local test environment and run pytest.

### 💻 Which operating system are you using?

Linux

### 🐍 Which Python version are you using?

3.8

### 📦 Installed packages

```shell
n/a
```

Contributor guide

Open the contributing guide

Research direction

Start with the development setup instructions in README.rst and compare them with the locale-generation step in .github/workflows/ci_cd.yml. Run pytest in a fresh Python 3.8 Linux environment to confirm the unsupported de_DE.UTF-8 failures. Done means the documented setup runs the test suite without the 47 locale-related failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.