When testing Vim do not rely on test order and do not save state

This commit refactors `TestVim` test class in test_configuration so that

1. `test_environ_update` does not leave state (value of `powerline_config_paths` 
   global Vim variable) behind other tests can use.
2. `test_local_themes` does not rely on state left from `test_environ_update`, 
   instead using new facility for providing needed value of 
   `Powerline.get_config_paths` call. This facility will be used later in BAR 
   tests.

Ref #1256
This commit is contained in:
ZyX 2015-01-25 01:58:27 +03:00
parent 8b17a19ebe
commit 332a266d87
2 changed files with 22 additions and 15 deletions

View File

@ -182,10 +182,17 @@ def select_renderer(simpler_renderer=False):
renderer = EvenSimplerRenderer if simpler_renderer else SimpleRenderer
def get_powerline_raw(helpers, PowerlineClass, **kwargs):
def get_powerline_raw(helpers, PowerlineClass, replace_gcp=False, **kwargs):
if not isinstance(helpers, TestHelpers):
helpers = TestHelpers(helpers)
select_renderer(kwargs.pop('simpler_renderer', False))
if replace_gcp:
class PowerlineClass(PowerlineClass):
@staticmethod
def get_config_paths():
return ['/']
pl = PowerlineClass(
config_loader=TestConfigLoader(
_helpers=helpers,

View File

@ -750,10 +750,10 @@ class TestVim(TestCase):
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
import vim
vim.vars['powerline_config_paths'] = ['/']
with swap_attributes(config, powerline_module):
with vim_module._with('environ', TEST='abc'):
with get_powerline_raw(config, VimPowerline) as powerline:
@ -769,7 +769,7 @@ class TestVim(TestCase):
from powerline.vim import VimPowerline
import powerline as powerline_module
with swap_attributes(config, powerline_module):
with get_powerline_raw(config, VimPowerline) as powerline:
with get_powerline_raw(config, VimPowerline, replace_gcp=True) as powerline:
powerline.add_local_theme('tests.matchers.always_true', {
'segment_data': {
'foo': {