GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_doctests failure when running tests with -werror on platforms without readline (win32, wasi) · Issue #128816 · python/cpython

test_doctests failure when running tests with -werror on platforms without readline (win32, wasi) #128816

New issue
Copy link
New issue
Copy link
Closed
Closed
test_doctests failure when running tests with -werror on platforms without readline (win32, wasi)#128816
Copy link
Labels
testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@graingert
graingert
opened on Jan 14, 2025
Issue body actions

Bug report

Bug description:

======================================================================
FAIL: test_lineendings (test.test_doctest.test_doctest)
Doctest: test.test_doctest.test_doctest.test_lineendings
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Lib/doctest.py", line 2327, in runTest
    raise self.failureException(self.format_failure(new.getvalue()))
AssertionError: Failed doctest test for test.test_doctest.test_doctest.test_lineendings
  File "/Lib/test/test_doctest/test_doctest.py", line 2901, in test_lineendings

----------------------------------------------------------------------
File "/Lib/test/test_doctest/test_doctest.py", line 2969, in test.test_doctest.test_doctest.test_lineendings
Failed example:
    with test_hook(dn):
        doctest.testfile("doctest_testfile.txt", package="doctest_testpkg", verbose=False)
Exception raised:
    Traceback (most recent call last):
      File "/Lib/doctest.py", line 1395, in __run
        exec(compile(example.source, filename, "single",
        ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                     compileflags, True), test.globs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest test.test_doctest.test_doctest.test_lineendings[21]>", line 2, in <module>
        doctest.testfile("doctest_testfile.txt", package="doctest_testpkg", verbose=False)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Lib/doctest.py", line 2197, in testfile
        runner.run(test)
        ~~~~~~~~~~^^^^^^
      File "/Lib/doctest.py", line 1548, in run
        self.debugger = _OutputRedirectingPdb(save_stdout)
                        ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
      File "/Lib/doctest.py", line 388, in __init__
        pdb.Pdb.__init__(self, stdout=out, nosigint=True)
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Lib/pdb.py", line 331, in __init__
        import readline
      File "<frozen importlib._bootstrap>", line 1359, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1330, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 918, in _load_unlocked
    ImportWarning: TestImporter.exec_module() not found; falling back to load_module()

fix seems to be to upgrade to the non-deprecated exec_module interface:

From 6659cadb6074c5c9203c26c4baedb47924c2f6d3 Mon Sep 17 00:00:00 2001
From: Thomas Grainger <[email protected]>
Date: Tue, 14 Jan 2025 08:56:11 +0000
Subject: [PATCH] fix an import warning in test_doctest.py when importing
 readline in WASI

---
 Lib/test/test_doctest/test_doctest.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Lib/test/test_doctest/test_doctest.py b/Lib/test/test_doctest/test_doctest.py
index b1e165fe16b..9c39255c241 100644
--- a/Lib/test/test_doctest/test_doctest.py
+++ b/Lib/test/test_doctest/test_doctest.py
@@ -2869,6 +2869,12 @@ def get_data(self, path):
         with open(path, mode='rb') as f:
             return f.read()
 
+    def exec_module(self, module):
+        raise ImportError
+
+    def create_module(self, spec):
+        return None
+
 class TestHook:
 
     def __init__(self, pathdir):
-- 
2.43.0

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows, Other

Linked PRs

  • gh-128816: fix an import warning in test_doctest.py when importing re… #128817
  • [3.13] gh-128816: Fix warnings in test_doctest (GH-128817) #128870
  • [3.12] gh-128816: Fix warnings in test_doctest (GH-128817) #128871

Activity

  1. graingert
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jan 14, 2025
  2. graingert
    added a commit that references this issue on Jan 14, 2025

    pythongh-128816: fix an import warning in test_doctest.py when import…

    6083317
  3. picnixz
    added
    testsTests in the Lib/test dirTests in the Lib/test dir
    on Jan 14, 2025
  4. serhiy-storchaka
    added a commit that references this issue on Jan 15, 2025

    gh-128816: Fix warnings in test_doctest (GH-128817)

    599be68
  5. miss-islington
    added 2 commits that reference this issue on Jan 15, 2025

    pythongh-128816: Fix warnings in test_doctest (pythonGH-128817)

    c57b161

    pythongh-128816: Fix warnings in test_doctest (pythonGH-128817)

    5b76a10
  6. serhiy-storchaka
    added 2 commits that reference this issue on Jan 16, 2025

    [3.13] gh-128816: Fix warnings in test_doctest (GH-128817) (GH-128870)

    c927fd9

    [3.12] gh-128816: Fix warnings in test_doctest (GH-128817) (GH-128871)

    45b89bf
  7. serhiy-storchaka
    closed this as completedon Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.