Description
An TypeError is raised at fake_popen.py:271 when calling with a file passed to argument stderr if no stderr was given during registration
> buffer.write(data_type(data))
E TypeError: encoding without a string argument
pyvenv\Lib\site-packages\pytest_subprocess\fake_popen.py:271: TypeError
Example
Below is an example demonstrating the error.
def test_fp_bug(fp):
with NamedTemporaryFile("wb", delete=False) as f:
fp.register(
["git", 'rev-parse', 'HEAD'],
stdout=["47c77698dd8e0e35af00da56806fe98fcb9a1056"],
)
p = subprocess.Popen(('git', 'rev-parse', 'HEAD'), stdout=f.file, stderr=f.file)
p.wait()
fp.allow_unregistered(True)
p = subprocess.Popen(('git', 'rev-parse', 'HEAD'), stdout=f.file, stderr=f.file)
p.wait()
This raises the type error. I can correct this:
--- fake_popen.py 2024-02-10 06:09:01.897909800 -0500
+++ fake_popen.py 2024-02-10 06:08:49.610943500 -0500
@@ -273,7 +267,7 @@
)
if isinstance(data, (list, tuple)):
buffer.writelines([data_type(line + "\n") for line in data])
- elif data is not None:
+ else:
buffer.write(data_type(data))
def _convert(self, input: Union[str, bytes]) -> Union[str, bytes]:
Description
An
TypeErroris raised atfake_popen.py:271 when calling with a file passed to argumentstderrif nostderrwas given during registrationExample
Below is an example demonstrating the error.
This raises the type error. I can correct this: