Exemplo n.º 1
0
    def test_wantOneDeprecated(self):
        """
        L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits
        a deprecation warning when invoked.
        """
        # Trigger the deprecation warning.
        helper._FormattingState().wantOne(bold=True)

        warningsShown = self.flushWarnings([self.test_wantOneDeprecated])
        self.assertEqual(len(warningsShown), 1)
        self.assertEqual(warningsShown[0]['category'], DeprecationWarning)
        self.assertEqual(
            warningsShown[0]['message'],
            'twisted.conch.insults.helper.wantOne was deprecated in '
            'Twisted 13.1.0')
Exemplo n.º 2
0
    def test_wantOneDeprecated(self):
        """
        L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits
        a deprecation warning when invoked.
        """
        # Trigger the deprecation warning.
        helper._FormattingState().wantOne(bold=True)

        warningsShown = self.flushWarnings([self.test_wantOneDeprecated])
        self.assertEqual(len(warningsShown), 1)
        self.assertIdentical(warningsShown[0]['category'], DeprecationWarning)
        self.assertEqual(
            warningsShown[0]['message'],
            'twisted.conch.insults.helper.wantOne was deprecated in '
            'Twisted 13.1.0')
Exemplo n.º 3
0
    def test_wantOneDeprecated(self):
        """
        L{twisted.conch.insults.helper.CharacterAttribute.wantOne} emits
        a deprecation warning when invoked.
        """
        # Trigger the deprecation warning.
        helper._FormattingState().wantOne(bold=True)

        warningsShown = self.flushWarnings([self.test_wantOneDeprecated])
        self.assertEqual(len(warningsShown), 1)
        self.assertEqual(warningsShown[0]["category"], DeprecationWarning)
        deprecatedClass = "twisted.conch.insults.helper._FormattingState.wantOne"
        self.assertEqual(
            warningsShown[0]["message"],
            "%s was deprecated in Twisted 13.1.0" % (deprecatedClass),
        )
Exemplo n.º 4
0
def assembleFormattedText(formatted):
    """
    Assemble formatted text from structured information.

    Currently handled formatting includes: bold, blink, reverse, underline and
    color codes.

    For example::

        from twisted.conch.insults.text import attributes as A
        assembleFormattedText(
            A.normal[A.bold['Time: '], A.fg.lightRed['Now!']])

    Would produce "Time: " in bold formatting, followed by "Now!" with a
    foreground color of light red and without any additional formatting.

    @param formatted: Structured text and attributes.

    @rtype: C{str}
    @return: String containing VT102 control sequences that mimic those
        specified by L{formatted}.

    @see: L{twisted.conch.insults.text.attributes}
    @since: 13.1
    """
    return _textattributes.flatten(
        formatted, helper._FormattingState(), 'toVT102')
Exemplo n.º 5
0
def assembleFormattedText(formatted):
    """
    Assemble formatted text from structured information.

    Currently handled formatting includes: bold, blink, reverse, underline and
    color codes.

    For example::

        from twisted.conch.insults.text import attributes as A
        assembleFormattedText(
            A.normal[A.bold['Time: '], A.fg.lightRed['Now!']])

    Would produce "Time: " in bold formatting, followed by "Now!" with a
    foreground color of light red and without any additional formatting.

    @param formatted: Structured text and attributes.

    @rtype: C{str}
    @return: String containing VT102 control sequences that mimic those
        specified by L{formatted}.

    @see: L{twisted.conch.insults.text.attributes}
    @since: 13.1
    """
    return _textattributes.flatten(formatted, helper._FormattingState(),
                                   'toVT102')
Exemplo n.º 6
0
 def _currentFormattingState(self):
     return helper._FormattingState(self.activeCharset,
                                    **self.graphicRendition)
Exemplo n.º 7
0
 def setUp(self):
     self.attrs = helper._FormattingState()
Exemplo n.º 8
0
 def setUp(self):
     self.attrs = helper._FormattingState()
Exemplo n.º 9
0
 def _currentFormattingState(self):
     return helper._FormattingState(self.activeCharset,
                                    **self.graphicRendition)