Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io.UnsupportedOperation when using rez api with pytest #965

Closed
spsalefeve opened this issue Oct 20, 2020 · 1 comment
Closed

io.UnsupportedOperation when using rez api with pytest #965

spsalefeve opened this issue Oct 20, 2020 · 1 comment

Comments

@spsalefeve
Copy link
Contributor

Hi,

I have the following issue when using rez API in my tests with pytest:

2020-10-08 09:27:59,859|setcontext|solve_util|l. 465| ERROR| Context couldn't be resolved.
Traceback (most recent call last):
  File "/app/package/int/setcontext/current/python/setcontext/solve_util.py", line 460, in _resolve
    resolved_context = ResolvedContext(package_list, **kwargs)
  File "/app/package/ext/rez/current/python/rez/resolved_context.py", line 208, in __init__
    for x in config.implicit_packages]
  File "/app/package/ext/rez/current/python/rez/utils/data_utils.py", line 191, in __get__
    result = self.func(instance)
  File "/app/package/ext/rez/current/python/rez/utils/data_utils.py", line 587, in getter
    return self._validate_key(key, attr, key_schema)
  File "/app/package/ext/rez/current/python/rez/config.py", line 614, in _validate_key
    return key_schema.validate(value)
  File "/app/package/ext/rez/current/python/rez/config.py", line 54, in validate
    data = expand_system_vars(data)
  File "/app/package/ext/rez/current/python/rez/config.py", line 783, in expand_system_vars
    return _expanded(data)
  File "/app/package/ext/rez/current/python/rez/config.py", line 778, in _expanded
    return [_expanded(x) for x in value]
  File "/app/package/ext/rez/current/python/rez/config.py", line 778, in <listcomp>
    return [_expanded(x) for x in value]
  File "/app/package/ext/rez/current/python/rez/config.py", line 776, in _expanded
    return scoped_format(value, system=system)
  File "/app/package/ext/rez/current/python/rez/utils/scope.py", line 262, in scoped_format
    return formatter.format(txt, pretty=pretty, expand=expand)
  File "/app/package/ext/rez/current/python/rez/utils/formatting.py", line 182, in format
    return formatter.format(s)
  File "/usr/local/lib/python3.7/string.py", line 186, in format
    return self.vformat(format_string, args, kwargs)
  File "/usr/local/lib/python3.7/string.py", line 190, in vformat
    result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
  File "/usr/local/lib/python3.7/string.py", line 230, in _vformat
    obj, arg_used = self.get_field(field_name, args, kwargs)
  File "/app/package/ext/rez/current/python/rez/utils/formatting.py", line 117, in get_field
    return Formatter.get_field(self, field_name, args, kwargs)
  File "/usr/local/lib/python3.7/string.py", line 301, in get_field
    obj = getattr(obj, i)
  File "/app/package/ext/rez/current/python/rez/utils/data_utils.py", line 191, in __get__
    result = self.func(instance)
  File "/app/package/ext/rez/current/python/rez/system.py", line 52, in os
    r = platform_.os
  File "/app/package/ext/rez/current/python/rez/utils/data_utils.py", line 191, in __get__
    result = self.func(instance)
  File "/app/package/ext/rez/current/python/rez/utils/platform_mapped.py", line 31, in inner
    result = func(*args, **kwargs)
  File "/app/package/ext/rez/current/python/rez/utils/platform_.py", line 33, in os
    return self._os()
  File "/app/package/ext/rez/current/python/rez/utils/platform_.py", line 231, in _os
    stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True
  File "/app/package/ext/rez/current/python/rez/utils/execution.py", line 54, in __init__
    file_no = sys.stdin.fileno()
  File "/app/package/ext/pytest/6.0.2/0195e0b9d4f737afb12e188f1abf4b9e01abb774/python/_pytest/capture.py", line 228, in fileno
    raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()")
io.UnsupportedOperation: redirected stdin is pseudofile, has no fileno()

Rez version : 2.68.4
Platform and operating system: Linux CentOS 7.6.1810
Contextual information:

  • Create a file test_main.py with the following content:
#!/usr/bin/env python
# coding: utf-8
"""Test rez log."""
from rez.resolved_context import ResolvedContext

def test_rez_log():
    # You can use another package you have
    context = ResolvedContext(["python"])
    print(context)

test_rez_log()
  • Run the script with rez API in the environment (I have rez API as a rez package) :
rez env rez --  ./test_main.py

Here is my result:

solved(python ~platform==linux ~arch==64bit ~os==CentOS-7.6.1810 pyarmor_runtime ==> platform-linux[] arch-64bit[] os-CentOS-7.6.1810[] python-3.7-sps.1.1[0] pyarmor_runtime-0.3.0[0])
  • Now try to run it as a pytest test:
rez env pytest pytest -- python -m pytest ./test_main.py

You should see the error appear. I will propose a Pull Request about this.

@nerdvegas
Copy link
Contributor

fixed by #966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants