def test_fbterm_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['term_escape_style'] = 'fbterm'
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1b[0m\x1b[1;5}\x1b[2;6}\xa0s\x1b[0m\x1b[1;6}\x1b[49m\x1b[22m>>\x1b[0m')
	def test_term_truecolor_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['term_truecolor'] = True
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1b[0;38;2;192;0;192;48;2;0;128;128m\xa0s\x1b[0;38;2;0;128;128;49;22m>>\x1b[0m')
	def test_term_truecolor_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['term_truecolor'] = True
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1b[0;38;2;192;0;192;48;2;0;128;128m\xa0s\x1b[0;38;2;0;128;128;49;22m>>\x1b[0m')
	def test_screen_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['additional_escapes'] = 'screen'
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1bP\x1b\x1b[0;38;5;5;48;5;6m\x1b\\\xa0s\x1bP\x1b\x1b[0;38;5;6;49;22m\x1b\\>>\x1bP\x1b\x1b[0m\x1b\\')
	def test_local_themes(self):
		# Regression test: VimPowerline.add_local_theme did not work properly.
		from powerline.vim import VimPowerline
		import powerline as powerline_module
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, VimPowerline, replace_gcp=True) as powerline:
				powerline.add_local_theme('tests.matchers.always_true', {
					'segment_data': {
						'foo': {
							'contents': '“bar”'
						}
					},
					'segments': {
						'left': [
							{
								'type': 'string',
								'name': 'foo',
								'highlight_groups': ['g1']
							}
						]
					}
				})
				window = vim_module.current.window
				window_id = 1
				winnr = window.number
				self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_5_12583104_6_32896_NONE#\xc2\xa0\xe2\x80\x9cbar\xe2\x80\x9d%#Pl_6_32896_NONE_None_NONE#>>')
	def test_fbterm_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['term_escape_style'] = 'fbterm'
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1b[0m\x1b[1;5}\x1b[2;6}\xa0s\x1b[0m\x1b[1;6}\x1b[49m\x1b[22m>>\x1b[0m')
	def test_screen_escapes(self, config):
		from powerline.shell import ShellPowerline
		import powerline as powerline_module
		config['config']['common']['additional_escapes'] = 'screen'
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, ShellPowerline, args=Args(config_path=[''])) as powerline:
				self.assertEqual(powerline.render(segment_info={}, side='left'), '\x1bP\x1b\x1b[0;38;5;5;48;5;6m\x1b\\\xa0s\x1bP\x1b\x1b[0;38;5;6;49;22m\x1b\\>>\x1bP\x1b\x1b[0m\x1b\\')
	def test_local_themes(self):
		# Regression test: VimPowerline.add_local_theme did not work properly.
		from powerline.vim import VimPowerline
		import powerline as powerline_module
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, VimPowerline, replace_gcp=True) as powerline:
				powerline.add_local_theme('tests.matchers.always_true', {
					'segment_data': {
						'foo': {
							'contents': '“bar”'
						}
					},
					'segments': {
						'left': [
							{
								'type': 'string',
								'name': 'foo',
								'highlight_groups': ['g1']
							}
						]
					}
				})
				window = vim_module.current.window
				window_id = 1
				winnr = window.number
				self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_5_12583104_6_32896_NONE#\xc2\xa0\xe2\x80\x9cbar\xe2\x80\x9d%#Pl_6_32896_NONE_None_NONE#>>')
	def test_lemonbar(self):
		import powerline as powerline_module
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, powerline_module.Powerline, replace_gcp=True, ext='wm', renderer_module='lemonbar') as powerline:
				self.assertRenderEqual(
					powerline,
					'%{l}%{F#ffc00000}%{B#ff008000}%{+u} A%{F-B--u}%{F#ff008000}%{B#ffc00000}>>%{F-B--u}%{F#ff008000}%{B#ffc00000}B%{F-B--u}%{F#ffc00000}>>%{F-B--u}%{r}%{F#ffc00000}<<%{F-B--u}%{F#ff804000}%{B#ffc00000}%{+u}C%{F-B--u}%{F#ff0000c0}%{B#ffc00000}<<%{F-B--u}%{F#ff008000}%{B#ff0000c0}D %{F-B--u}'
				)
	def test_bar(self):
		import powerline as powerline_module
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, powerline_module.Powerline, replace_gcp=True, ext='wm', renderer_module='bar') as powerline:
				self.assertRenderEqual(
					powerline,
					'%{l}%{F#ffc00000}%{B#ff008000}%{+u} A%{F-B--u}%{F#ff008000}%{B#ffc00000}>>%{F-B--u}%{F#ff008000}%{B#ffc00000}B%{F-B--u}%{F#ffc00000}>>%{F-B--u}%{r}%{F#ffc00000}<<%{F-B--u}%{F#ff804000}%{B#ffc00000}%{+u}C%{F-B--u}%{F#ff0000c0}%{B#ffc00000}<<%{F-B--u}%{F#ff008000}%{B#ff0000c0}D %{F-B--u}'
				)
 def test_escapes(self, config):
     from powerline.shell import ShellPowerline
     import powerline as powerline_module
     with swap_attributes(config, powerline_module):
         with get_powerline_raw(config,
                                ShellPowerline,
                                args=Args(config_path=[''])) as powerline:
             self.assertEqual(
                 powerline.render(segment_info={}, side='left'),
                 '\x1b[0;38;5;5;48;5;6m\xa0s\x1b[0;38;5;6;49;22m>>\x1b[0m')
 def test_escapes(self, config):
     from powerline.shell import ShellPowerline
     import powerline as powerline_module
     with swap_attributes(config, powerline_module):
         with get_powerline_raw(
                 config, ShellPowerline,
                 args=Args(config_path=[''])) as powerline:
             self.assertEqual(
                 powerline.render(segment_info={}, side='left'),
                 '\x1b[0;38;5;5;48;5;6m\xa0s\x1b[0;38;5;6;49;22m>>\x1b[0m')
Beispiel #13
0
	def test_environ_update(self):
		# Regression test: test that segment obtains environment from vim, not 
		# from os.environ.
		from powerline.vim import VimPowerline
		with vim_module._with('environ', TEST='abc'):
			with get_powerline_raw(VimPowerline) as powerline:
				window = vim_module.current.window
				window_id = 1
				winnr = window.number
				self.assertEqual(powerline.render(window, window_id, winnr), '%#Pl_3_8404992_4_192_underline#\xa0abc%#Pl_4_192_NONE_None_NONE#>>')
				vim_module._environ['TEST'] = 'def'
				self.assertEqual(powerline.render(window, window_id, winnr), '%#Pl_3_8404992_4_192_underline#\xa0def%#Pl_4_192_NONE_None_NONE#>>')
	def test_bar_escape(self, config):
		import powerline as powerline_module
		config['themes/wm/default']['segments']['left'] = (
			highlighted_string('%{asd}', 'hl1'),
			highlighted_string('10% %', 'hl2'),
		)
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, powerline_module.Powerline, replace_gcp=True, ext='wm', renderer_module='bar') as powerline:
				self.assertRenderEqual(
					powerline,
					'%{l}%{F#ffc00000}%{B#ff008000}%{+u} %%{asd}%{F-B--u}%{F#ff008000}%{B#ffc00000}>>%{F-B--u}%{F#ff008000}%{B#ffc00000}10%% %%%{F-B--u}%{F#ffc00000}>>%{F-B--u}%{r}%{F#ffc00000}<<%{F-B--u}%{F#ff804000}%{B#ffc00000}%{+u}C%{F-B--u}%{F#ff0000c0}%{B#ffc00000}<<%{F-B--u}%{F#ff008000}%{B#ff0000c0}D %{F-B--u}'
				)
Beispiel #15
0
	def test_lemonbar_escape(self, config):
		import powerline as powerline_module
		config['themes/wm/default']['segments']['left'] = (
			highlighted_string('%{asd}', 'hl1'),
			highlighted_string('10% %', 'hl2'),
		)
		with swap_attributes(config, powerline_module):
			with get_powerline_raw(config, powerline_module.Powerline, replace_gcp=True, ext='wm', renderer_module='lemonbar') as powerline:
				self.assertRenderEqual(
					powerline,
					'%{l}%{F#ffc00000}%{B#ff008000}%{+u} %%{}{asd}%{F-B--u}%{F#ff008000}%{B#ffc00000}>>%{F-B--u}%{F#ff008000}%{B#ffc00000}10%%{} %%{}%{F-B--u}%{F#ffc00000}>>%{F-B--u}%{r}%{F#ffc00000}<<%{F-B--u}%{F#ff804000}%{B#ffc00000}%{+u}C%{F-B--u}%{F#ff0000c0}%{B#ffc00000}<<%{F-B--u}%{F#ff008000}%{B#ff0000c0}D %{F-B--u}'
				)
Beispiel #16
0
	def test_environ_update(self):
		# Regression test: test that segment obtains environment from vim, not 
		# from os.environ.
		import tests.vim as vim_module
		with vim_module._with('globals', powerline_config_paths=['/']):
			from powerline.vim import VimPowerline
			import powerline as powerline_module
			with swap_attributes(config, powerline_module):
				with vim_module._with('environ', TEST='abc'):
					with get_powerline_raw(config, VimPowerline) as powerline:
						window = vim_module.current.window
						window_id = 1
						winnr = window.number
						self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_3_8404992_4_192_underline#\xc2\xa0abc%#Pl_4_192_NONE_None_NONE#>>')
						vim_module._environ['TEST'] = 'def'
						self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_3_8404992_4_192_underline#\xc2\xa0def%#Pl_4_192_NONE_None_NONE#>>')
	def test_environ_update(self):
		# Regression test: test that segment obtains environment from vim, not 
		# from os.environ.
		import tests.vim as vim_module
		with vim_module._with('globals', powerline_config_paths=['/']):
			from powerline.vim import VimPowerline
			import powerline as powerline_module
			with swap_attributes(config, powerline_module):
				with vim_module._with('environ', TEST='abc'):
					with get_powerline_raw(config, VimPowerline) as powerline:
						window = vim_module.current.window
						window_id = 1
						winnr = window.number
						self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_3_8404992_4_192_underline#\xc2\xa0abc%#Pl_4_192_NONE_None_NONE#>>')
						vim_module._environ['TEST'] = 'def'
						self.assertEqual(powerline.render(window, window_id, winnr), b'%#Pl_3_8404992_4_192_underline#\xc2\xa0def%#Pl_4_192_NONE_None_NONE#>>')