Example #1
0
 def __repr__(self):
     return text("test")
Example #2
0
from io import StringIO

from expecter import expect
from nose2.tools import params

from jnrbase.compat import text
from jnrbase.context import chdir
from jnrbase import config

from .utils import mock_path_exists, patch, patch_env


@params((True, 4), (False, 3))
@mock_path_exists()
@patch.object(config, "open", lambda s, encoding: StringIO(text("")))
def test_config_loading(local, count):
    with patch_env({"XDG_CONFIG_DIRS": "test1:test2"}):
        cfg = config.read_configs("jnrbase", local=local)
    expect(len(cfg.configs)) == count
    if local:
        expect(cfg.configs[-1]).contains("/.jnrbaserc")
    else:
        expect(cfg.configs).does_not_contain("/.jnrbaserc")


@mock_path_exists(False)
def test_config_loading_missing_files():
    expect(config.read_configs("jnrbase").configs) == []