File: test_commands.py

package info (click to toggle)
pytest-watcher 0.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 856 kB
  • sloc: python: 925; makefile: 28; sh: 13
file content (29 lines) | stat: -rw-r--r-- 868 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from pytest_watcher import commands
from pytest_watcher.config import Config
from pytest_watcher.terminal import Terminal
from pytest_watcher.trigger import Trigger


def test_run_command(trigger: Trigger, config: Config, mock_terminal: Terminal):
    class DummyCommand(commands.Command):
        character = "0"
        caption = "0"
        description = "test"
        show_in_menu = False

        def __init__(self):
            self.invoked = False

        def run(self, trigger: Trigger, term: Terminal, config: Config) -> None:
            self.invoked = True

    command = commands.Manager.get_command("0")

    assert isinstance(command, DummyCommand)
    assert command.invoked is False

    commands.Manager.run_command("0", trigger, mock_terminal, config)

    assert command.invoked is True

    commands.Manager._registry.pop(DummyCommand.character)