Skip to content

Error with 3.13.3 and 3.13.4: AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue' #284

@philgyford

Description

@philgyford

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:

...
test_logs_favicon_saved (tests.directory.favicons.test_favicons.FaviconFetcherTestCase)
It should INFO log where the favicon was saved to ... ok
Used shuffle seed: 937773765 (generated)
Destroying test database for alias 'default' ('test_oohdir_1')...
Destroying test database for alias 'default' ('test_oohdir_2')...
Destroying test database for alias 'default' ('test_oohdir_3')...
Destroying test database for alias 'default' ('test_oohdir_4')...
Destroying test database for alias 'default' ('test_oohdir_5')...
Destroying test database for alias 'default' ('test_oohdir_6')...
Destroying test database for alias 'default' ('test_oohdir_7')...
Destroying test database for alias 'default' ('test_oohdir_8')...
Destroying test database for alias 'default' ('test_oohdir')...
Traceback (most recent call last):
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/manage.py", line 23, in <module>
    main()
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/commands/test.py", line 24, in run_from_argv
    super().run_from_argv(argv)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/core/management/commands/test.py", line 63, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/test/runner.py", line 1073, in run_tests
    result = self.run_suite(suite)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/test/runner.py", line 1000, in run_suite
    return runner.run(suite)
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/runner.py", line 184, in run
    test(result)
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/suite.py", line 84, in __call__
    return self.run(*args, **kwds)
  File "/Users/phil/Projects/personal/ooh-directory/oohdir/.venv/lib/python3.10/site-packages/django/test/runner.py", line 556, in run
    handler(test, *args)
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/runner.py", line 68, in addError
    super(TextTestResult, self).addError(test, err)
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/result.py", line 17, in inner
    return method(self, *args, **kw)
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/result.py", line 115, in addError
    self.errors.append((test, self._exc_info_to_string(err, test)))
  File "/Users/phil/.local/share/uv/python/cpython-3.10.13-macos-aarch64-none/lib/python3.10/unittest/result.py", line 183, in _exc_info_to_string
    output = sys.stdout.getvalue()
AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue'

I get the same error running the tests in GitHub Actions on a different platform from macOS:

  File "/home/runner/.local/share/uv/python/cpython-3.10.13-linux-x86_64-gnu/lib/python3.10/unittest/result.py", line 183, in _exc_info_to_string
    output = sys.stdout.getvalue()
AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue'

Sorry that I don't have replicable code for this yet, but it seems consistent enough to report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions