import pytest
import npc
import os
from tests.util import fixture_dir

def test_creation(prefs):
    assert prefs is not None

def test_override(prefs):
    override_path = fixture_dir('settings/settings-vim.json')
    old_editor = prefs.get('editor')
    prefs.load_more(override_path)
    assert prefs.get('editor') != old_editor

def test_nested_get(prefs):
    assert prefs.get('paths.characters') == 'Characters'

def test_get_settings_path(prefs):
    assert prefs.get_settings_path('default') == os.path.join(prefs.default_settings_path, 'settings-default.json')
    assert prefs.get_settings_path('campaign') == os.path.join(prefs.campaign_settings_path, 'settings.json')

@pytest.mark.parametrize('settings_type', ['changeling', 'werewolf'])
def test_get_typed_settings_path(prefs, settings_type):
    fetched_path = prefs.get_settings_path('default', settings_type)
    assert fetched_path == os.path.join(prefs.default_settings_path, 'settings-{}.json'.format(settings_type))

def test_support_paths(prefs):
    """Paths loaded from additional files should be expanded relative to that file"""
    override_path = fixture_dir('settings/settings-paths.json')
    prefs.load_more(override_path)
    assert prefs.get('support.testpath') == fixture_dir('settings/nothing.json')

@@ -179,33 +179,36 @@
 re_dir('settings
-/
+', '
 settings-vim.jso
@@ -1142,17 +1142,20 @@
 settings
-/
+', '
 settings
@@ -1272,9 +1272,12 @@
 ings
-/
+', '
 noth

Fix fixture_dir usage