Exemplo n.º 1
0
    def test_not_detected(self):
        """Test terminal emulator (non-)detection, without Unicode support"""
        terminal = Terminal()

        output_mock = MagicMock()
        terminal.output(output_mock)
        output = output_mock.append.call_args[0][1]

        self.assertIsNone(terminal.value)
        self.assertTrue(output.startswith(DEFAULT_CONFIG['default_strings']['not_detected']))
        self.assertFalse(output.count('\u2588'))
Exemplo n.º 2
0
    def test_terminal_emulator_term_fallback_and_unicode(self):
        """Check that `TERM` is honored if present, and Unicode support for the colors palette"""
        terminal = Terminal()

        output_mock = MagicMock()
        terminal.output(output_mock)

        self.assertEqual(terminal.value, 'xterm-256color')
        self.assertTrue(
            output_mock.append.call_args[0][1].startswith('xterm-256color'))
        self.assertEqual(output_mock.append.call_args[0][1].count('\u2588'),
                         7 * 2)
Exemplo n.º 3
0
    def test_no_color(self):
        """Test `Terminal` output behavior when `NO_COLOR` is set (palette should be hidden)"""
        with patch('archey.entries.terminal.Environment', Mock(NO_COLOR=True)):
            terminal = Terminal()

            output_mock = MagicMock()
            terminal.output(output_mock)

            self.assertEqual(terminal.value, 'X-TERMINAL-EMULATOR')
            self.assertEqual(
                output_mock.append.call_args[0][1],
                'X-TERMINAL-EMULATOR'
            )
Exemplo n.º 4
0
    def test_color_disabling(self):
        """Test `Terminal` output behavior when coloration has been disabled"""
        with patch('archey.colors.Colors.should_color_output', return_value=False):
            terminal = Terminal()

            output_mock = MagicMock()
            terminal.output(output_mock)

            self.assertEqual(terminal.value, 'X-TERMINAL-EMULATOR')
            self.assertEqual(
                output_mock.append.call_args[0][1],
                'X-TERMINAL-EMULATOR'
            )
Exemplo n.º 5
0
    def test_no_color(self):
        """Test `Terminal` output behavior when `NO_COLOR` is set (palette should be hidden)"""
        with patch(
                'archey.entries.terminal.NO_COLOR',
                True  # Temporary disable color for this test.
            ):
            terminal = Terminal()

            output_mock = MagicMock()
            terminal.output(output_mock)

            self.assertEqual(terminal.value, 'X-TERMINAL-EMULATOR')
            self.assertEqual(
                output_mock.append.call_args[0][1],
                'X-TERMINAL-EMULATOR'
            )
Exemplo n.º 6
0
 def test_terminal_emulator_colorterm_override(self):
     """
     Check we observe terminal using `COLORTERM` even if `TERM` or a "known identifier" is found.
     """
     self.assertEqual(Terminal().value, 'KMSCON')
Exemplo n.º 7
0
 def test_terminal_emulator_colorterm(self):
     """Check we can detect terminals using the `COLORTERM` environment variable."""
     self.assertEqual(Terminal().value, 'KMSCON')
Exemplo n.º 8
0
 def test_terminal_emulator_name_normalization(self):
     """Check that our manual terminal detection as long as name normalization are working"""
     self.assertEqual(Terminal().value, 'Konsole')
Exemplo n.º 9
0
 def test_terminal_emulator_special_term(self):
     """Check that `TERM` is honored even if a "known identifier" could be found"""
     self.assertEqual(Terminal().value, 'OH-A-SPECIAL-CASE')
Exemplo n.º 10
0
 def test_terminal_emulator_term_program(self):
     """Check that `TERM_PROGRAM` is honored even if `TERM` or `COLORTERM` is defined"""
     self.assertEqual(Terminal().value, 'A-COOL-TERMINAL-EMULATOR')
Exemplo n.º 11
0
 def test_not_detected(self, _, __):
     """Test simple output, with Unicode support !"""
     output = Terminal().value
     self.assertTrue(output.startswith('Not detected '))
     self.assertEqual(output.count('#'), 7 * 2)
Exemplo n.º 12
0
 def test_with_unicode(self, _, __):
     """Test simple output, with Unicode support !"""
     output = Terminal().value
     self.assertTrue(output.startswith('TERMINAL '))
     self.assertEqual(output.count('\u2588'), 7 * 2)
Exemplo n.º 13
0
 def test_without_unicode(self, _, __):
     """Test simple output, without Unicode support (default)"""
     output = Terminal().value
     self.assertTrue(output.startswith('TERMINAL '))
     self.assertEqual(output.count('#'), 7 * 2)
Exemplo n.º 14
0
 def test_terminal_emulator_term_program_version(self):
     """Check that `TERM_PROGRAM` and `TERM_PROGRAM_VERSION` are correctly honored"""
     self.assertEqual(Terminal().value, 'A-COOL-TERMINAL-EMULATOR vX.Y.Z-beta42')