Skip to content
Snippets Groups Projects
Commit 1be9168c authored by Georges Racinet's avatar Georges Racinet
Browse files

testhelpers: testing extensions in load/init

parent d3d787f2
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,12 @@
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
from mercurial import (
extensions,
)
from ..testhelpers import (
LocalRepoWrapper,
NULL_ID,
NULL_REVISION,
)
......@@ -5,8 +9,11 @@
from ..testhelpers import (
LocalRepoWrapper,
NULL_ID,
NULL_REVISION,
)
import hgext3rd.heptapod
HGEXT_HEPTA_SOURCE = hgext3rd.heptapod.__file__.replace('.pyc', '.py')
def test_init_write_commit(tmpdir):
......@@ -24,3 +31,34 @@
reloaded = LocalRepoWrapper.load(tmpdir)
rl_ctx = reloaded.repo[node]
assert rl_ctx.description() == 'Foo committed'
def assert_is_hepta_ext(hepta_ext):
assert hepta_ext is not None
# it's imported with a different name, hence can't be directly compared
# let's also avoid flakiness due to __file__ behaviour depending on
# installation context
assert hepta_ext.__doc__ == hgext3rd.heptapod.__doc__
def test_load_hgrc_extension(tmpdir):
LocalRepoWrapper.init(tmpdir)
tmpdir.join('.hg', 'hgrc').write('\n'.join((
"[extensions]",
"heptapod=" + HGEXT_HEPTA_SOURCE,
)))
wrapper = LocalRepoWrapper.load(tmpdir)
exts = dict(extensions.extensions(wrapper.repo.ui))
assert_is_hepta_ext(exts.get('heptapod'))
def test_init_config_extension(tmpdir):
from mercurial import ui as uimod
ui = uimod.ui.load()
ui.setconfig('foo', 'bar', 'yes', source='tests')
ui.setconfig('extensions', 'heptapod', HGEXT_HEPTA_SOURCE, source='tests')
wrapper = LocalRepoWrapper.init(tmpdir, base_ui=ui)
assert wrapper.repo.ui.configbool('foo', 'bar')
exts = dict(extensions.extensions(wrapper.repo.ui))
assert_is_hepta_ext(exts.get('heptapod'))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment