-
Notifications
You must be signed in to change notification settings - Fork 42
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
Error with 3.13.3 and 3.13.4: AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue' #284
Comments
Oh, and in case you wonder, it's the same if I don't run the tests with |
@philgyford this stacktrace is about |
Yes I realise that. I was sharing what I have so far after some hours of narrowing it down. If I make more progress tomorrow I will share that. |
This is probably useless to you, so feel free to close it, but here's where I've got to. I have this function and a test for it: import requests
from django.test import TestCase
from mocket import mocketize
from mocket.mockhttp import Entry
from mocket.plugins.httpretty import httprettified, httpretty
def fetch():
try:
response = requests.get("https://example.org/")
response.raise_for_status()
except:
return False
else:
return response
class FetchTestCase(TestCase):
@mocketize
@httprettified
def test_fetch(self):
httpretty.register_uri(httpretty.HEAD, "https://example.org/", "hello")
Entry.single_register(Entry.GET, "https://example.org/", exception=OSError())
result = fetch()
self.assertFalse(result) I get the error when I have mocket 3.13.3 or 3.13.4 installed, but only when I also run a bunch of other tests in the same app, which don't use mocket. I never get the error when mocket 3.13.2 is installed. And, crucially, I never get the error if I comment out I've also found, only when not running tests in parallel, that the error trace above is preceded by:
Why it has that problem with the db connection only when I'm using As I say, it doesn't seem to be something I can narrow down further to a reliable single piece of code that causes the error, sorry. |
Why are you using both |
In the end they are the very same thing (see here): httprettified = mocketize |
You are the second person who writes here for something similar, but I still have nothing useful for trying to replicate the problem. :( |
@philgyford Could you please replace |
This said, the code runs normally for me:
Of course I am not loading a Django project. |
Because I use And, you know what... when I remove |
Happy to read that! I could not replicate your problem but at least I know that is something I should explore more. |
When I run the tests in one of my apps – which includes one set of tests that use mocket – they quit with an error 90% of the time when I'm using mocket 3.13.3 or 3.13.4, but run fine with 3.13.2.
I've spent hours trying to narrow it down and can't pin it down to a specific test. If I only run the set of tests that use mocket, they usually work. I can try and pin it down more tomorrow, but I've run out of time today.
When the testing fails it always aborts after one of the tests that uses mocket. Here's the output:
I get the same error running the tests in GitHub Actions on a different platform from macOS:
Sorry that I don't have replicable code for this yet, but it seems consistent enough to report.
The text was updated successfully, but these errors were encountered: