-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
2.0.4: pytest is failing in two units #692
Comments
I am making a change so that pytest finds the tests easier. The test failures appear to be unique to your environment. It looks to be related to your setting of PYTHONPATH, but I cannot be sure. |
Currently that methodology is widely used during packaging across Fedora and Debian. |
Yes the tests do alter the PYTHONPATH as well, here. Do you have any idea why the test environment may not be respecting the alterations? |
No idea .. 😞 |
FYI: as long as looks like this issue is strictly related to test suite and not to the tested code I've added in my build procedure those two units to --deselect list so it is not kind of critical issue. |
Just retested 2.0.6 and I see that still one unit is failing Here is pytest output:+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-sh-2.0.6-5.fc36.x86_64/usr/lib64/python3.9/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-sh-2.0.6-5.fc36.x86_64/usr/lib/python3.9/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.9.18, pytest-8.1.1, pluggy-1.4.0
rootdir: /home/tkloczko/rpmbuild/BUILD/sh-2.0.6
configfile: pyproject.toml
collected 179 items
tests/sh_test.py .....Fs............................................................................................................................................................. [ 91%]
............... [100%]
========================================================================================= FAILURES ==========================================================================================
_____________________________________________________________________________ FunctionalTests.test_environment ______________________________________________________________________________
self = <tests.sh_test.FunctionalTests testMethod=test_environment>
def test_environment(self):
"""tests that environments variables that we pass into sh commands
exist in the environment, and on the sh module"""
import os
# this is the environment we'll pass into our commands
env = {"HERP": "DERP"}
# first we test that the environment exists in our child process as
# we've set it
py = create_tmp_test(
"""
import os
for key in list(os.environ.keys()):
if key != "HERP":
del os.environ[key]
print(dict(os.environ))
"""
)
out = python(py.name, _env=env).strip()
self.assertEqual(out, "{'HERP': 'DERP'}")
py = create_tmp_test(
"""
import os, sys
sys.path.insert(0, os.getcwd())
import sh
for key in list(os.environ.keys()):
if key != "HERP":
del os.environ[key]
print(dict(HERP=sh.HERP))
"""
)
> out = python(py.name, _env=env, _cwd=THIS_DIR).strip()
tests/sh_test.py:561:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sh.py:1508: in __call__
rc = self.__class__.RunningCommandCls(cmd, call_args, stdin, stdout, stderr)
sh.py:737: in __init__
self.wait()
sh.py:799: in wait
self.handle_command_exit_code(exit_code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = , code = 1
def handle_command_exit_code(self, code):
"""here we determine if we had an exception, or an error code that we
weren't expecting to see. if we did, we create and raise an exception
"""
ca = self.call_args
exc_class = get_exc_exit_code_would_raise(code, ca["ok_code"], ca["piped"])
if exc_class:
exc = exc_class(
self.ran, self.process.stdout, self.process.stderr, ca["truncate_exc"]
)
> raise exc
E sh.ErrorReturnCode_1:
E
E RAN: /usr/bin/python3 /tmp/tmploev9u33
E
E STDOUT:
E
E
E STDERR:
E Traceback (most recent call last):
E File "/tmp/tmploev9u33", line 4, in <module>
E import sh
E ModuleNotFoundError: No module named 'sh'
sh.py:826: ErrorReturnCode_1
===================================================================================== warnings summary ======================================================================================
tests/sh_test.py::FunctionalTests::test_piped_exception1
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822369
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_2:
RAN: /usr/bin/python3 /tmp/tmpdr759avs
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_unchecked_pipeline_failure
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822409
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_2:
RAN: /usr/bin/python3 /tmp/tmp5jpqf11u
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_signal_exception
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822487
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.SignalException_SIGTERM:
RAN: /usr/bin/python3 /tmp/tmpywy3tq5j
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_piped_exception2
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822547
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_2:
RAN: /usr/bin/python3 /tmp/tmp5d2lbaku
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_fg_alternative
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread STDIN thread for pid 822582
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2591, in input_thread
done = stdin.write()
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2904, in write
chunk = self.get_chunk()
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2845, in fn
chunk = stdin.read(bufsize)
File "/usr/lib/python3.9/site-packages/_pytest/capture.py", line 207, in read
raise OSError(
OSError: pytest: reading from stdin while output is captured! Consider using `-s`.
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_stdout_callback_terminate
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822778
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.SignalException_SIGTERM:
RAN: /usr/bin/python3 -u /tmp/tmp0edtxg5s
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_signal_group
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822843
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.SignalException_SIGKILL:
RAN: /usr/bin/python3 /tmp/tmpk7tedzaj
STDOUT:
822847
822843
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_exit_code_with_hasattr
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822866
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_3:
RAN: /usr/bin/python3 /tmp/tmpgsgg71kw
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_multiple_bakes
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 822852
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.SignalException_SIGKILL:
RAN: /usr/bin/python3 /tmp/tmpk7tedzaj
STDOUT:
822856
822852
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_done_cb_exc
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 823156
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /usr/bin/python3 /tmp/tmphy6rcpcq
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_stdout_callback_kill
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 823210
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.SignalException_SIGKILL:
RAN: /usr/bin/python3 -u /tmp/tmpzt1iowt3
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
tests/sh_test.py::FunctionalTests::test_unchecked_producer_failure
/usr/lib/python3.9/site-packages/_pytest/threadexception.py:77: PytestUnhandledThreadExceptionWarning: Exception in thread background thread for pid 823295
Traceback (most recent call last):
File "/usr/lib64/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 1639, in wrap
fn(*rgs, **kwargs)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2641, in background_thread
handle_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 2332, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/tkloczko/rpmbuild/BUILD/sh-2.0.6/sh.py", line 826, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_2:
RAN: /usr/bin/python3 /tmp/tmpeg6orsaf
STDOUT:
STDERR:
warnings.warn(pytest.PytestUnhandledThreadExceptionWarning(msg))
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
SKIPPED [1] tests/sh_test.py:2322: what's the best way to test a different '_encoding' special keywordargument?
FAILED tests/sh_test.py::FunctionalTests::test_environment - sh.ErrorReturnCode_1:
============================================================= 1 failed, 177 passed, 1 skipped, 12 warnings in 60.92s (0:01:00) ============================================================== |
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulescut off from access to the public network
(pytest is executed with-m "not network"
)First of all pytest by default is not able to find units because by default pytest scans only pests_*py files
After specify
tests/test.py
as paramHere is list of installed modules in build env
The text was updated successfully, but these errors were encountered: