Add tests for the constantly recreated *Powerline instances

This commit is contained in:
ZyX 2013-03-19 00:42:32 +04:00
parent 1dc039a3b0
commit 260a0dafcb
1 changed files with 29 additions and 6 deletions

View File

@ -15,6 +15,17 @@ VBLOCK = chr(ord('V') - 0x40)
SBLOCK = chr(ord('S') - 0x40) SBLOCK = chr(ord('S') - 0x40)
def shutdown(powerline):
from powerline.segments import common, vim
try:
powerline.renderer.shutdown()
finally:
# After shutdown threads are useless, it is needed to recreate them.
from imp import reload
reload(common)
reload(vim)
class TestConfig(TestCase): class TestConfig(TestCase):
def test_vim(self): def test_vim(self):
from powerline.vim import VimPowerline from powerline.vim import VimPowerline
@ -49,7 +60,7 @@ class TestConfig(TestCase):
check_output(1, 0) check_output(1, 0)
finally: finally:
vim_module._start_mode('n') vim_module._start_mode('n')
powerline.renderer.shutdown() shutdown(powerline)
def test_tmux(self): def test_tmux(self):
from powerline.segments import common from powerline.segments import common
@ -57,16 +68,27 @@ class TestConfig(TestCase):
reload(common) reload(common)
from powerline.shell import ShellPowerline from powerline.shell import ShellPowerline
with replace_module_attr(common, 'urllib_read', urllib_read): with replace_module_attr(common, 'urllib_read', urllib_read):
ShellPowerline(Args(ext=['tmux']), run_once=True).renderer.render() powerline = ShellPowerline(Args(ext=['tmux']), run_once=False)
reload(common) powerline.renderer.render()
powerline = ShellPowerline(Args(ext=['tmux']), run_once=False)
powerline.renderer.render()
shutdown(powerline)
def test_zsh(self): def test_zsh(self):
from powerline.shell import ShellPowerline from powerline.shell import ShellPowerline
ShellPowerline(Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt'), run_once=True).renderer.render() powerline = ShellPowerline(Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt'), run_once=False)
powerline.renderer.render()
powerline = ShellPowerline(Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt'), run_once=False)
powerline.renderer.render()
shutdown(powerline)
def test_bash(self): def test_bash(self):
from powerline.shell import ShellPowerline from powerline.shell import ShellPowerline
ShellPowerline(Args(last_exit_code=1, ext=['shell'], renderer_module='bash_prompt', config=[('ext', {'shell': {'theme': 'default_leftonly'}})]), run_once=True).renderer.render() powerline = ShellPowerline(Args(last_exit_code=1, ext=['shell'], renderer_module='bash_prompt', config=[('ext', {'shell': {'theme': 'default_leftonly'}})]), run_once=False)
powerline.renderer.render()
powerline = ShellPowerline(Args(last_exit_code=1, ext=['shell'], renderer_module='bash_prompt', config=[('ext', {'shell': {'theme': 'default_leftonly'}})]), run_once=False)
powerline.renderer.render()
shutdown(powerline)
def test_ipython(self): def test_ipython(self):
from powerline.ipython import IpythonPowerline from powerline.ipython import IpythonPowerline
@ -78,7 +100,8 @@ class TestConfig(TestCase):
powerline = IpyPowerline() powerline = IpyPowerline()
powerline.renderer.render() powerline.renderer.render()
powerline.renderer.shutdown() powerline.renderer.render()
shutdown(powerline)
def test_wm(self): def test_wm(self):
from powerline.segments import common from powerline.segments import common