Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Lib/_pyrepl/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Event:

@dataclass
class Console(ABC):
posxy: tuple[int, int]
screen: list[str] = field(default_factory=list)
posxy: tuple[int, int] = field(default=(0, 0), repr=False)
screen: list[str] = field(default_factory=list, repr=False)
height: int = 25
width: int = 80

Expand Down
20 changes: 20 additions & 0 deletions Lib/test/test_pyrepl/test_pyrepl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,26 @@ def test_dumb_terminal_exits_cleanly(self):
self.assertNotIn("Traceback", output)


class TestConsoleRepr(TestCase):

def test_console_repr_with_missing_attributes(self):
from _pyrepl.unix_console import UnixConsole
console = UnixConsole()

repr_str = repr(console)

self.assertIsInstance(repr_str, str)
self.assertIn("UnixConsole", repr_str)

def test_readline_wrapper_repr_after_import(self):
import _pyrepl.readline

wrapper = _pyrepl.readline._wrapper
if wrapper is not None and wrapper.reader is not None:
repr_str = repr(wrapper.reader)
self.assertIsInstance(repr_str, str)


@skipUnless(pty, "requires pty")
@skipIf((os.environ.get("TERM") or "dumb") == "dumb", "can't use pyrepl in dumb terminal")
class TestMain(ReplTestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix: make dataclass Console init right to avoid has no attribute 'posxy'
error
Loading