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'))
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)
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' )
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' )
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' )