Exemplo n.º 1
0
	def test_reload_main(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')

			config['config']['common']['default_top_theme'] = 'other'
			add_watcher_events(p, 'config')
			p.render()
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/other', 'check:themes/test/__main__', 'themes/test/default')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['theme'] = 'nonexistent'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:themes/test/nonexistent', 'themes/other', 'check:themes/test/__main__')
			# It should normally handle file missing error
			self.assertEqual(p.logger._pop_msgs(), [
				'exception:test:powerline:Failed to load theme: themes/test/__main__',
				'exception:test:powerline:Failed to load theme: themes/test/nonexistent',
				'exception:test:powerline:Failed to create renderer: themes/test/nonexistent'
			])

			config['config']['ext']['test']['theme'] = 'default'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/test/default', 'themes/other', 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['colorscheme'] = 'nonexistent'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:colorschemes/nonexistent', 'check:colorschemes/test/__main__', 'check:colorschemes/test/nonexistent')
			# It should normally handle file missing error
			self.assertEqual(p.logger._pop_msgs(), [
				'exception:test:powerline:Failed to load colorscheme: colorschemes/nonexistent',
				'exception:test:powerline:Failed to load colorscheme: colorschemes/test/__main__',
				'exception:test:powerline:Failed to load colorscheme: colorschemes/test/nonexistent',
				'exception:test:powerline:Failed to create renderer: colorschemes/test/nonexistent'
			])

			config['config']['ext']['test']['colorscheme'] = '2'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> s <3 4 False>>><1 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:colorschemes/2', 'check:colorschemes/test/__main__', 'colorschemes/test/2')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['theme'] = '2'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/test/2', 'themes/other', 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])

			self.assertEqual(p.renderer.local_themes, None)
			config['config']['ext']['test']['local_themes'] = 'something'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config')
			self.assertEqual(p.logger._pop_msgs(), [])
			self.assertEqual(p.renderer.local_themes, 'something')
Exemplo n.º 2
0
    def test_reload_theme_main(self, config):
        config['config']['common']['interval'] = None
        with get_powerline(config, run_once=False) as p:
            self.assertEqual(
                p.render(),
                '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
            )
            self.assertAccessEvents(p, 'config', 'colors',
                                    'check:colorschemes/default',
                                    'check:colorschemes/test/__main__',
                                    'colorschemes/test/default',
                                    'themes/test/default', 'themes/powerline',
                                    'check:themes/test/__main__')

            config['themes/test/default']['segments']['left'][0][
                'contents'] = 'col3'
            add_watcher_events(p, 'themes/test/default', wait=False)
            self.assertEqual(
                p.render(),
                '<1 2 1> col3<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
            )
            self.assertAccessEvents(p, 'themes/test/default',
                                    'themes/powerline',
                                    'check:themes/test/__main__')
            self.assertEqual(p.logger._pop_msgs(), [])
            self.assertTrue(p._watcher._calls)
Exemplo n.º 3
0
	def test_reload_unexistent(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')

			config['config']['ext']['test']['colorscheme'] = 'nonexistentraise'
			add_watcher_events(p, 'config')
			# It may appear that p.logger._pop_msgs() is called after given 
			# exception is added to the mesagges, but before config_loader 
			# exception was added (this one: 
			# “exception:test:config_loader:Error while running condition 
			# function for key colorschemes/test/nonexistentraise: 
			# fcf:colorschemes/test/nonexistentraise”).
			# sleep(0.1)
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			# For colorschemes/{test/,}*raise find_config_file raises 
			# IOError, but it does not do so for check:colorschemes/test/__main__, 
			# so powerline is trying to load this, but not other 
			# colorschemes/*
			self.assertAccessEvents(p, 'config', 'check:colorschemes/test/__main__', 'check:colorschemes/nonexistentraise', 'check:colorschemes/test/nonexistentraise')
			self.assertIn('exception:test:powerline:Failed to create renderer: fcf:colorschemes/test/nonexistentraise', p.logger._pop_msgs())

			config['colorschemes/nonexistentraise'] = {}
			config['colorschemes/test/nonexistentraise'] = {
				'groups': {
					'str1': {'fg': 'col1', 'bg': 'col3', 'attrs': ['bold']},
					'str2': {'fg': 'col2', 'bg': 'col4', 'attrs': ['underline']},
				},
			}
			while not p._will_create_renderer():
				sleep(0.1)
			self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>')
			# Same as above
			self.assertAccessEvents(p, 'colorschemes/nonexistentraise', 'colorschemes/test/nonexistentraise', 'check:colorschemes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 4
0
	def test_reload_unexistent(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['config']['ext']['test']['colorscheme'] = 'nonexistentraise'
				add_watcher_events(p, 'config')
				# It may appear that p.logger._pop_msgs() is called after given 
				# exception is added to the mesagges, but before config_loader 
				# exception was added (this one: 
				# “exception:test:config_loader:Error while running condition 
				# function for key colorschemes/test/nonexistentraise: 
				# fcf:colorschemes/test/nonexistentraise”).
				# sleep(0.1)
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertIn('exception:test:powerline:Failed to create renderer: fcf:colorschemes/test/nonexistentraise', p.logger._pop_msgs())

				config['colorschemes/test/nonexistentraise'] = {
					'groups': {
						"str1": {"fg": "col1", "bg": "col3", "attr": ["bold"]},
						"str2": {"fg": "col2", "bg": "col4", "attr": ["underline"]},
					},
				}
				while not p._will_create_renderer():
					sleep(0.000001)
				self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('colorschemes/test/nonexistentraise')
				self.assertEqual(p.logger._pop_msgs(), [])
		pop_events()
Exemplo n.º 5
0
	def test_reload_main(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')

			config['config']['common']['default_top_theme'] = 'other'
			add_watcher_events(p, 'config')
			p.render()
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/other', 'check:themes/test/__main__', 'themes/test/default')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['theme'] = 'nonexistent'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:themes/test/nonexistent', 'themes/other', 'check:themes/test/__main__')
			# It should normally handle file missing error
			self.assertEqual(p.logger._pop_msgs(), [
				'exception:test:powerline:Failed to load theme: themes/test/__main__',
				'exception:test:powerline:Failed to load theme: themes/test/nonexistent',
				'exception:test:powerline:Failed to create renderer: themes/test/nonexistent'
			])

			config['config']['ext']['test']['theme'] = 'default'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/test/default', 'themes/other', 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['colorscheme'] = 'nonexistent'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:colorschemes/nonexistent', 'check:colorschemes/test/__main__', 'check:colorschemes/test/nonexistent')
			# It should normally handle file missing error
			self.assertEqual(p.logger._pop_msgs(), [
				'exception:test:powerline:Failed to load colorscheme: colorschemes/nonexistent',
				'exception:test:powerline:Failed to load colorscheme: colorschemes/test/__main__',
				'exception:test:powerline:Failed to load colorscheme: colorschemes/test/nonexistent',
				'exception:test:powerline:Failed to create renderer: colorschemes/test/nonexistent'
			])

			config['config']['ext']['test']['colorscheme'] = '2'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> s <3 4 False>>><1 4 4>g <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'check:colorschemes/2', 'check:colorschemes/test/__main__', 'colorschemes/test/2')
			self.assertEqual(p.logger._pop_msgs(), [])

			config['config']['ext']['test']['theme'] = '2'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'themes/test/2', 'themes/other', 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])

			self.assertEqual(p.renderer.local_themes, None)
			config['config']['ext']['test']['local_themes'] = 'something'
			add_watcher_events(p, 'config')
			self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config')
			self.assertEqual(p.logger._pop_msgs(), [])
			self.assertEqual(p.renderer.local_themes, 'something')
Exemplo n.º 6
0
	def test_reload_unexistent(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')

			config['config']['ext']['test']['colorscheme'] = 'nonexistentraise'
			add_watcher_events(p, 'config')
			# It may appear that p.logger._pop_msgs() is called after given 
			# exception is added to the mesagges, but before config_loader 
			# exception was added (this one: 
			# “exception:test:config_loader:Error while running condition 
			# function for key colorschemes/test/nonexistentraise: 
			# fcf:colorschemes/test/nonexistentraise”).
			# sleep(0.1)
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			# For colorschemes/{test/,}*raise find_config_file raises 
			# IOError, but it does not do so for check:colorschemes/test/__main__, 
			# so powerline is trying to load this, but not other 
			# colorschemes/*
			self.assertAccessEvents(p, 'config', 'check:colorschemes/test/__main__', 'check:colorschemes/nonexistentraise', 'check:colorschemes/test/nonexistentraise')
			self.assertIn('exception:test:powerline:Failed to create renderer: fcf:colorschemes/test/nonexistentraise', p.logger._pop_msgs())

			config['colorschemes/nonexistentraise'] = {}
			config['colorschemes/test/nonexistentraise'] = {
				'groups': {
					"str1": {"fg": "col1", "bg": "col3", "attr": ["bold"]},
					"str2": {"fg": "col2", "bg": "col4", "attr": ["underline"]},
				},
			}
			while not p._will_create_renderer():
				sleep(0.1)
			self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>')
			# Same as above
			self.assertAccessEvents(p, 'colorschemes/nonexistentraise', 'colorschemes/test/nonexistentraise', 'check:colorschemes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 7
0
	def test_noreload(self, config):
		with get_powerline(config, run_once=True) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')
			config['config']['common']['spaces'] = 1
			add_watcher_events(p, 'config', wait=False, interval=0.05)
			# When running once thread should not start
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p)
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 8
0
	def test_reload_colorscheme(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')

			config['colorschemes/test/default']['groups']['str1']['bg'] = 'col3'
			add_watcher_events(p, 'colorschemes/test/default')
			self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 9
0
	def test_reload_top_theme(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')

			config['themes/powerline']['dividers']['left']['hard'] = '|>'
			add_watcher_events(p, 'themes/powerline')
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>|><3 4 4>g<4 False False>|><None None None>')
			self.assertAccessEvents(p, 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 10
0
	def test_reload_top_theme(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')

			config['themes/' + UT]['dividers']['left']['hard'] = '|>'
			add_watcher_events(p, 'themes/' + UT)
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>|><3 4 4>g<4 False False>|><None None None>')
			self.assertAccessEvents(p, 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 11
0
	def test_reload_colorscheme(self, config):
		with get_powerline(config, run_once=False) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')

			config['colorschemes/test/default']['groups']['str1']['bg'] = 'col3'
			add_watcher_events(p, 'colorschemes/test/default')
			self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default')
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 12
0
	def test_noreload(self, config):
		with get_powerline(config, run_once=True) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/' + UT, 'check:themes/test/__main__')
			config['config']['common']['spaces'] = 1
			add_watcher_events(p, 'config', wait=False, interval=0.05)
			# When running once thread should not start
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p)
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 13
0
	def test_run_once_no_theme_reload(self, config):
		config['config']['common']['interval'] = None
		with get_powerline(config, run_once=True) as p:
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p, 'config', 'colors', 'check:colorschemes/default', 'check:colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default', 'themes/powerline', 'check:themes/test/__main__')

			config['themes/test/default']['segments']['left'][0]['contents'] = 'col3'
			add_watcher_events(p, 'themes/test/default', wait=False)
			self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
			self.assertAccessEvents(p)
			self.assertEqual(p.logger._pop_msgs(), [])
Exemplo n.º 14
0
	def test_reload_theme(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['themes/test/default']['segments']['left'][0]['contents'] = 'col3'
				add_watcher_events(p, 'themes/test/default')
				self.assertEqual(p.render(), '<1 2 1> col3<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('themes/test/default')
				self.assertEqual(p.logger._pop_msgs(), [])
		pop_events()
Exemplo n.º 15
0
    def test_reload_unexistent(self):
        with get_powerline(run_once=False) as p:
            with replace_item(globals(), 'config', deepcopy(config)):
                self.assertEqual(
                    p.render(),
                    '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('config', 'colors',
                                        'colorschemes/test/default',
                                        'themes/test/default')

                config['config']['ext']['test'][
                    'colorscheme'] = 'nonexistentraise'
                add_watcher_events(p, 'config')
                # It may appear that p.logger._pop_msgs() is called after given
                # exception is added to the mesagges, but before config_loader
                # exception was added (this one:
                # “exception:test:config_loader:Error while running condition
                # function for key colorschemes/test/nonexistentraise:
                # fcf:colorschemes/test/nonexistentraise”).
                # sleep(0.1)
                self.assertEqual(
                    p.render(),
                    '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('config')
                self.assertIn(
                    'exception:test:powerline:Failed to create renderer: fcf:colorschemes/test/nonexistentraise',
                    p.logger._pop_msgs())

                config['colorschemes/test/nonexistentraise'] = {
                    'groups': {
                        "str1": {
                            "fg": "col1",
                            "bg": "col3",
                            "attr": ["bold"]
                        },
                        "str2": {
                            "fg": "col2",
                            "bg": "col4",
                            "attr": ["underline"]
                        },
                    },
                }
                while not p._will_create_renderer():
                    sleep(0.000001)
                self.assertEqual(
                    p.render(),
                    '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('colorschemes/test/nonexistentraise')
                self.assertEqual(p.logger._pop_msgs(), [])
        pop_events()
Exemplo n.º 16
0
	def test_reload_theme(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/default', 'colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default')

				config['themes/test/default']['segments']['left'][0]['contents'] = 'col3'
				add_watcher_events(p, 'themes/test/default')
				self.assertEqual(p.render(), '<1 2 1> col3<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('themes/test/default')
				self.assertEqual(p.logger._pop_msgs(), [])
		pop_events()
Exemplo n.º 17
0
	def test_with_above(self, config):
		old_segments = deepcopy(config['themes/test/default']['segments'])
		config['themes/test/default']['segments']['above'] = [old_segments]
		with get_powerline(config, run_once=True, simpler_renderer=True) as p:
			self.assertRenderLinesEqual(p, [
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
			])
			self.assertRenderLinesEqual(p, [
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
			], width=10)

		config['themes/test/default']['segments']['above'] = [old_segments] * 2
		with get_powerline(config, run_once=True, simpler_renderer=True) as p:
			self.assertRenderLinesEqual(p, [
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
			])
			self.assertRenderLinesEqual(p, [
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
			], width=10)
Exemplo n.º 18
0
	def test_with_above(self, config):
		old_segments = deepcopy(config['themes/test/default']['segments'])
		config['themes/test/default']['segments']['above'] = [old_segments]
		with get_powerline(config, run_once=True, simpler_renderer=True) as p:
			self.assertRenderLinesEqual(p, [
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
			])
			self.assertRenderLinesEqual(p, [
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
			], width=10)

		config['themes/test/default']['segments']['above'] = [old_segments] * 2
		with get_powerline(config, run_once=True, simpler_renderer=True) as p:
			self.assertRenderLinesEqual(p, [
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
				'{121} s{24}>>{344}g{34}>{34}|{344}f {--}',
			])
			self.assertRenderLinesEqual(p, [
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
				'{121} s {24}>>{344}g{34}>{34}|{344}f {--}',
			], width=10)
Exemplo n.º 19
0
	def test_reload_main(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['config']['common']['spaces'] = 1
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['theme'] = 'nonexistent'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/nonexistent')
				# It should normally handle file missing error
				self.assertEqual(p.logger._pop_msgs(), ['exception:test:powerline:Failed to create renderer: themes/test/nonexistent'])

				config['config']['ext']['test']['theme'] = 'default'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/default')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['colorscheme'] = 'nonexistent'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colorschemes/test/nonexistent')
				# It should normally handle file missing error
				self.assertEqual(p.logger._pop_msgs(), ['exception:test:powerline:Failed to create renderer: colorschemes/test/nonexistent'])

				config['config']['ext']['test']['colorscheme'] = '2'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> s <3 4 False>>><1 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colorschemes/test/2')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['theme'] = '2'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/2')
				self.assertEqual(p.logger._pop_msgs(), [])

				self.assertEqual(p.renderer.local_themes, None)
				config['config']['ext']['test']['local_themes'] = 'something'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertEqual(p.logger._pop_msgs(), [])
				self.assertEqual(p.renderer.local_themes, 'something')
		pop_events()
Exemplo n.º 20
0
	def test_reload_main(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['config']['common']['spaces'] = 1
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['theme'] = 'nonexistent'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/nonexistent')
				# It should normally handle file missing error
				self.assertEqual(p.logger._pop_msgs(), ['exception:test:Failed to create renderer: themes/test/nonexistent'])

				config['config']['ext']['test']['theme'] = 'default'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/default')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['colorscheme'] = 'nonexistent'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s <2 4 False>>><3 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colorschemes/test/nonexistent')
				# It should normally handle file missing error
				self.assertEqual(p.logger._pop_msgs(), ['exception:test:Failed to create renderer: colorschemes/test/nonexistent'])

				config['config']['ext']['test']['colorscheme'] = '2'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> s <3 4 False>>><1 4 4>g <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colorschemes/test/2')
				self.assertEqual(p.logger._pop_msgs(), [])

				config['config']['ext']['test']['theme'] = '2'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
				self.assertAccessEvents('config', 'themes/test/2')
				self.assertEqual(p.logger._pop_msgs(), [])

				self.assertEqual(p.renderer.local_themes, None)
				config['config']['ext']['test']['local_themes'] = 'something'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<2 3 1> t <3 4 False>>><1 4 4>b <4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertEqual(p.logger._pop_msgs(), [])
				self.assertEqual(p.renderer.local_themes, 'something')
		pop_events()
Exemplo n.º 21
0
	def test_run_once_no_theme_reload(self):
		with replace_item(globals(), 'config', deepcopy(config)):
			config['config']['common']['interval'] = None
			with get_powerline(run_once=True) as p:
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['themes/test/default']['segments']['left'][0]['contents'] = 'col3'
				add_watcher_events(p, 'themes/test/default', wait=False)
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents()
				self.assertEqual(p.logger._pop_msgs(), [])
				self.assertEqual(p._watcher._calls, [])
		pop_events()
Exemplo n.º 22
0
	def test_noreload(self):
		with get_powerline(run_once=True) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/default', 'colorschemes/test/__main__', 'colorschemes/test/default', 'themes/test/default')
				config['config']['common']['spaces'] = 1
				add_watcher_events(p, 'config', wait=False, interval=0.05)
				# When running once thread should not start
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents()
				self.assertEqual(p.logger._pop_msgs(), [])
		# Without the following assertion test_reload_colors may fail for 
		# unknown reason (with AssertionError telling about “config” accessed 
		# one more time then needed)
		pop_events()
Exemplo n.º 23
0
	def test_noreload(self):
		with get_powerline(run_once=True) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')
				config['config']['common']['spaces'] = 1
				add_watcher_events(p, 'config', wait=False, interval=0.05)
				# When running once thread should not start
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents()
				self.assertEqual(p.logger._pop_msgs(), [])
		# Without the following assertion test_reload_colors may fail for 
		# unknown reason (with AssertionError telling about “config” accessed 
		# one more time then needed)
		pop_events()
Exemplo n.º 24
0
    def test_reload_unexistent(self):
        with get_powerline(run_once=False) as p:
            with replace_item(globals(), 'config', deepcopy(config)):
                self.assertEqual(
                    p.render(),
                    '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('config', 'colors',
                                        'colorschemes/test/default',
                                        'themes/test/default')

                config['config']['ext']['test'][
                    'colorscheme'] = 'nonexistentraise'
                add_watcher_events(p, 'config')
                self.assertEqual(
                    p.render(),
                    '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('config')
                self.assertIn(
                    'exception:test:Failed to create renderer: fcf:colorschemes/test/nonexistentraise',
                    p.logger._pop_msgs())

                config['colorschemes/test/nonexistentraise'] = {
                    'groups': {
                        "str1": {
                            "fg": "col1",
                            "bg": "col3",
                            "attr": ["bold"]
                        },
                        "str2": {
                            "fg": "col2",
                            "bg": "col4",
                            "attr": ["underline"]
                        },
                    },
                }
                while not p._will_create_renderer():
                    sleep(0.000001)
                self.assertEqual(
                    p.render(),
                    '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>'
                )
                self.assertAccessEvents('colorschemes/test/nonexistentraise')
                self.assertEqual(p.logger._pop_msgs(), [])
        pop_events()
Exemplo n.º 25
0
	def test_reload_unexistent(self):
		with get_powerline(run_once=False) as p:
			with replace_item(globals(), 'config', deepcopy(config)):
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config', 'colors', 'colorschemes/test/default', 'themes/test/default')

				config['config']['ext']['test']['colorscheme'] = 'nonexistentraise'
				add_watcher_events(p, 'config')
				self.assertEqual(p.render(), '<1 2 1> s<2 4 False>>><3 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('config')
				self.assertIn('exception:test:Failed to create renderer: fcf:colorschemes/test/nonexistentraise', p.logger._pop_msgs())

				config['colorschemes/test/nonexistentraise'] = {
					'groups': {
						"str1": {"fg": "col1", "bg": "col3", "attr": ["bold"]},
						"str2": {"fg": "col2", "bg": "col4", "attr": ["underline"]},
					},
				}
				while not p._will_create_renderer():
					sleep(0.000001)
				self.assertEqual(p.render(), '<1 3 1> s<3 4 False>>><2 4 4>g<4 False False>>><None None None>')
				self.assertAccessEvents('colorschemes/test/nonexistentraise')
				self.assertEqual(p.logger._pop_msgs(), [])
		pop_events()
Exemplo n.º 26
0
	def f(self):
		new_config = deepcopy(config)
		with get_powerline(new_config, run_once=True, simpler_renderer=True) as p:
			func(self, p, new_config)
Exemplo n.º 27
0
	def f(self):
		with get_powerline(run_once=True, simpler_renderer=True) as p:
			func(self, p)
Exemplo n.º 28
0
	def f(self):
		new_config = deepcopy(config)
		with get_powerline(new_config, run_once=True, simpler_renderer=True) as p:
			func(self, p, new_config)