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

AttributeError: 'FakePipeWrapper' object has no attribute 'readable' #650

Closed
MasterSergius opened this issue Dec 3, 2021 · 17 comments
Closed

Comments

@MasterSergius
Copy link

Describe the bug
I have a set of tests using fake fs and vcr cassetess. When I try to run it, I have the following error:

            if c2pread != -1:
                self.stdout = io.open(c2pread, 'rb', bufsize)
                if self.text_mode:
>                   self.stdout = io.TextIOWrapper(self.stdout,
                            encoding=encoding, errors=errors)
E                           AttributeError: 'FakePipeWrapper' object has no attribute 'readable'
subprocess.py:850: AttributeError

This error appeared when I tried to run tests in a bit newer environment:

Python              3.8.12
-----------------------
pyfakefs           4.5.3
pytest              6.2.5
pytest-asyncio     0.16.0
pytest-mock        3.6.1
pytest-recording   0.12.0

It works within the following (older) environment:

Python              3.8.2
-----------------------
pyfakefs                          4.3.0
pytest                            6.1.2
pytest-asyncio                    0.14.0
pytest-mock                       3.3.1
pytest-recording                  0.10.0

How To Reproduce
pytest --record-mode=once tests

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Dec 3, 2021

Hm, can you show your actual test, or a minimal reproducible example? Are you using subprocess or multiprocessing in your tested code? Both are known to have problems with pyfakefs. Though given that it is the pytest environment that has changed, it probably is an incompatibility with one of the other plugins...

@MasterSergius
Copy link
Author

Ok, I wanted to contribute to this library https://github.com/okta/okta-sdk-python, so I tried to run tests if everything is fine, you can check tests/integration folder

@mrbean-bremen
Copy link
Member

Ok, I will check if I can reproduce it, thanks.

@mrbean-bremen
Copy link
Member

What OS you are using? I'm currently under Windows, and here this is not reproducible with the same environment.

@MasterSergius
Copy link
Author

MacOS 10.15.17

@mrbean-bremen
Copy link
Member

Ok, I just checked their own CI tests which use the same versions under Ubuntu and also work, so I guess this is a MacOS-specific problem. Unfortunately, I don't have a Mac, so I'm not sure how to reproduce this, but I'm afraid it has to with subprocess using some OS-specific functions. As mentioned, subprocess does not always work with pyfakefs due to that (pyfakefs cannot only patch Python functions, not C functions), and I just noticed that the callstack is indeed in subprocess.py. I will have a look at that code, but I'm afraid that you are out of luck here.
If you want to contribute to that repo, you probably have to rely on their CI for the time being.

@mrbean-bremen
Copy link
Member

I checked the code, and I may actually be able to fix this - maybe all it takes is to patch a couple of functions for the fake pipe. I cannot guarantee that it will work after the fix, but we can try it.

@MasterSergius
Copy link
Author

@mrbean-bremen ok, anyway, thank you for the fast response

mrbean-bremen added a commit that referenced this issue Dec 3, 2021
- add readable, writable and seekable
- see #650
@mrbean-bremen
Copy link
Member

@MasterSergius - can you please check how it behaves with pyfakefs master?

github-actions bot pushed a commit that referenced this issue Dec 3, 2021
@MasterSergius
Copy link
Author

MasterSergius commented Dec 6, 2021

@mrbean-bremen Looks fine, it works

@mrbean-bremen
Copy link
Member

Ok, thanks - do you need a patch release?

@MasterSergius
Copy link
Author

No, I can use it now, so you can release when u're ready to.

@mrbean-bremen
Copy link
Member

Ok, thanks - closing this then.

@julienschuermans
Copy link

Hi @mrbean-bremen, thanks for your amazing work!
I've got the same issue. When are you planning to release the fix?

@mrbean-bremen
Copy link
Member

I can make a patch release tonight, if you need it.

@julienschuermans
Copy link

That would be great, thanks a lot!

@mrbean-bremen
Copy link
Member

Ok, done.

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

3 participants