Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Rename test classes in backend_test
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Mar 25, 2022
1 parent e61cdbb commit 1f3b652
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/sage/repl/rich_output/backend_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
sage: from sage.repl.rich_output import get_display_manager
sage: dm = get_display_manager()
sage: from sage.repl.rich_output.backend_test import BackendTest, TestObject
sage: from sage.repl.rich_output.backend_test import BackendTest, _TestObject
sage: doctest_backend = dm.switch_backend(BackendTest())
sage: dm
The Sage display manager using the test backend
sage: dm._output_promotions
{<class 'sage.repl.rich_output.output_basic.OutputPlainText'>:
<class 'sage.repl.rich_output.backend_test.TestOutputPlainText'>}
<class 'sage.repl.rich_output.backend_test._TestOutputPlainText'>}
sage: dm.displayhook(1/2)
1/2 [TestOutputPlainText]
TestOutputPlainText container
1/2 [_TestOutputPlainText]
_TestOutputPlainText container
sage: test = TestObject()
sage: test = _TestObject()
sage: test
called the _repr_ method
sage: dm.displayhook(test)
called the _rich_repr_ method [TestOutputPlainText]
TestOutputPlainText container
called the _rich_repr_ method [_TestOutputPlainText]
_TestOutputPlainText container
"""

#*****************************************************************************
Expand All @@ -45,7 +45,7 @@
from sage.repl.rich_output.output_catalog import OutputPlainText, OutputImagePng


class TestOutputPlainText(OutputPlainText):
class _TestOutputPlainText(OutputPlainText):

def __init__(self, *args, **kwds):
"""
Expand All @@ -60,8 +60,8 @@ def __init__(self, *args, **kwds):
EXAMPLES::
sage: from sage.repl.rich_output.backend_test import TestOutputPlainText
sage: TestOutputPlainText()
sage: from sage.repl.rich_output.backend_test import _TestOutputPlainText
sage: _TestOutputPlainText()
Traceback (most recent call last):
...
AssertionError: cannot override constructor
Expand All @@ -79,16 +79,16 @@ def print_to_stdout(self):
sage: from sage.repl.rich_output import get_display_manager
sage: dm = get_display_manager()
sage: test_output = dm.displayhook(123)
123 [TestOutputPlainText]
123 [_TestOutputPlainText]
sage: type(test_output)
<class 'sage.repl.rich_output.backend_test.TestOutputPlainText'>
<class 'sage.repl.rich_output.backend_test._TestOutputPlainText'>
sage: test_output.print_to_stdout()
123 [TestOutputPlainText]
123 [_TestOutputPlainText]
"""
print('{0} [{1}]'.format(self.text.get_str(), self.__class__.__name__))


class TestObject(SageObject):
class _TestObject(SageObject):
"""
Test object with both :meth:`_repr_` and :meth:`_rich_repr_`
"""
Expand All @@ -103,8 +103,8 @@ def _repr_(self):
EXAMPLES::
sage: from sage.repl.rich_output.backend_test import TestObject
sage: obj = TestObject()
sage: from sage.repl.rich_output.backend_test import _TestObject
sage: obj = _TestObject()
sage: obj._repr_()
'called the _repr_ method'
"""
Expand All @@ -119,8 +119,8 @@ def _rich_repr_(self, display_manager):
EXAMPLES::
sage: display_manager = sage.repl.rich_output.get_display_manager()
sage: from sage.repl.rich_output.backend_test import TestObject
sage: obj = TestObject()
sage: from sage.repl.rich_output.backend_test import _TestObject
sage: obj = _TestObject()
sage: rich_output = obj._rich_repr_(display_manager); rich_output
OutputPlainText container
sage: rich_output.text.get_str()
Expand Down Expand Up @@ -157,23 +157,23 @@ def supported_output(self):
OUTPUT:
Iterable of output container classes. Only the
:class:`~sage.repl.rich_repr.backend_test.TestOutputPlainText`
:class:`~sage.repl.rich_repr.backend_test._TestOutputPlainText`
output container is supported by the test backend.
EXAMPLES::
sage: display_manager = sage.repl.rich_output.get_display_manager()
sage: backend = display_manager._backend
sage: list(backend.supported_output())
[<class 'sage.repl.rich_output.backend_test.TestOutputPlainText'>]
[<class 'sage.repl.rich_output.backend_test._TestOutputPlainText'>]
The output of this method is used by the display manager to
set up the actual supported outputs. Compare::
sage: list(display_manager.supported_output())
[<class 'sage.repl.rich_output.output_basic.OutputPlainText'>]
"""
return set([TestOutputPlainText])
return set([_TestOutputPlainText])

def display_immediately(self, plain_text, rich_output):
"""
Expand Down

0 comments on commit 1f3b652

Please sign in to comment.