Skip to content

Commit

Permalink
Run black and flake8 on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lbonn committed Feb 5, 2024
1 parent e3376b1 commit 6562720
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ runs:
pip install -e .
- id: black
shell: bash
run: black --check --diff i3_quickterm setup.py
run: black --check --diff i3_quickterm tests setup.py
- id: flake8
shell: bash
run: flake8 i3_quickterm
run: flake8 i3_quickterm tests
- id: pytest
shell: bash
run: pytest -vv
52 changes: 32 additions & 20 deletions tests/test_i3quickterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ def i3ipc_connection(i3ipc_con):
@pytest.fixture
def conf(tmpdir):
c = copy.deepcopy(DEFAULT_CONF)
c.update({
"menu": "/bin/true",
"shells": {"shell": "bash"},
"verbose": True,
"history": f"{str(tmpdir)}/shells.order",
})
c.update(
{
"menu": "/bin/true",
"shells": {"shell": "bash"},
"verbose": True,
"history": f"{str(tmpdir)}/shells.order",
}
)
return c


Expand All @@ -67,12 +69,16 @@ def test_launch_inplace(i3ipc_connection, conf, execvp):

qt.launch_inplace()

i3ipc_connection.command.assert_has_calls([
call("mark quickterm_shell"),
call("[con_mark=quickterm_shell] move scratchpad, scratchpad show, "
"resize set 0 px 0 px, move absolute position 0px 0px"),
])
execvp.assert_called_once_with('bash', ['bash'])
i3ipc_connection.command.assert_has_calls(
[
call("mark quickterm_shell"),
call(
"[con_mark=quickterm_shell] move scratchpad, scratchpad show, "
"resize set 0 px 0 px, move absolute position 0px 0px"
),
]
)
execvp.assert_called_once_with("bash", ["bash"])


def test_execute_term(i3ipc_connection, i3ipc_con, conf, execvp):
Expand All @@ -83,7 +89,7 @@ def test_execute_term(i3ipc_connection, i3ipc_con, conf, execvp):

qt.execute_term()

execvp.assert_has_calls([call('urxvt', ANY)])
execvp.assert_has_calls([call("urxvt", ANY)])


def test_toggle_hide(i3ipc_connection, conf, execvp):
Expand All @@ -93,7 +99,8 @@ def test_toggle_hide(i3ipc_connection, conf, execvp):
qt.toggle_on_current_ws()

i3ipc_connection.command.assert_called_once_with(
'[con_id=0] floating enable, move scratchpad')
"[con_id=0] floating enable, move scratchpad"
)
assert execvp.call_count == 0


Expand All @@ -110,15 +117,20 @@ def new_workspace():
ws.rect = i3ipc.Rect({"x": 0, "y": 0, "height": 0, "width": 0})
k += 1
return ws

i3ipc_con.workspace.side_effect = new_workspace

qt.toggle_on_current_ws()

i3ipc_connection.command.assert_has_calls([
call('[con_id=0] floating enable, move scratchpad'),
call('[con_mark=quickterm_shell] move scratchpad, scratchpad show, '
'resize set 0 px 0 px, move absolute position 0px 0px'),
])
i3ipc_connection.command.assert_has_calls(
[
call("[con_id=0] floating enable, move scratchpad"),
call(
"[con_mark=quickterm_shell] move scratchpad, scratchpad show, "
"resize set 0 px 0 px, move absolute position 0px 0px"
),
]
)
assert execvp.call_count == 0


Expand Down Expand Up @@ -154,7 +166,7 @@ def test_run_qt_noshell_select_none(quickterm_mock):

run_qt(qt)

assert qt.shell == None
assert qt.shell is None


def test_run_qt_noshell_select_one(quickterm_mock):
Expand Down

0 comments on commit 6562720

Please sign in to comment.