Skip to content

Commit

Permalink
tests: format test_alias.py
Browse files Browse the repository at this point in the history
Formatting test_alias.py is trivial.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
  • Loading branch information
pdgendt committed Nov 8, 2024
1 parent 5ea42a8 commit 4a9c26e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

assert 'TOXTEMPDIR' in os.environ, "you must run these tests using tox"


@pytest.fixture(autouse=True)
def autouse_tmpdir(config_tmpdir, west_init_tmpdir):
# Since this module tests west's configuration file features,
# adding autouse=True to the config_tmpdir and west_init_tmpdir fixtures
# saves typing and is less error-prone than using it below in every test case.
pass


def test_alias_commands():
cmd('config alias.test1 topdir')
cmd('config --global alias.test2 topdir')
Expand All @@ -28,6 +30,7 @@ def test_alias_commands():
assert cmd('test2') == topdir_out
assert cmd('test3') == topdir_out


def test_alias_help():
cmd('config alias.test topdir')

Expand All @@ -36,13 +39,15 @@ def test_alias_help():
assert "An alias that expands to: topdir" in help_out
assert cmd('-h test') == help_out


def test_alias_recursive_commands():
list_format = '{revision} TESTALIAS {name}'
cmd(['config', 'alias.test1', f'list -f "{list_format}"'])
cmd('config alias.test2 test1')

assert cmd('test2') == cmd(['list', '-f', list_format])


def test_alias_infinite_recursion():
cmd('config alias.test1 test2')
cmd('config alias.test2 test3')
Expand All @@ -53,6 +58,7 @@ def test_alias_infinite_recursion():

assert 'unknown command "test1";' in str(excinfo.value.stdout)


def test_alias_empty():
cmd(['config', 'alias.empty', ''])

Expand All @@ -64,18 +70,21 @@ def test_alias_empty():

assert 'empty alias "empty"' in str(excinfo.value.stdout)


def test_alias_early_args():
cmd('config alias.test1 topdir')

# An alias with an early command argument shouldn't fail
assert "Replacing alias test1 with ['topdir']" in cmd('-v test1')


def test_alias_command_with_arguments():
list_format = '{revision} TESTALIAS {name}'
cmd(['config', 'alias.revs', f'list -f "{list_format}"'])

assert cmd('revs') == cmd(['list', '-f', list_format])


def test_alias_override():
before = cmd('list')
list_format = '{name} : {revision}'
Expand Down

0 comments on commit 4a9c26e

Please sign in to comment.