File: test_event_handler_log_command.py

package info (click to toggle)
ros2-colcon-core 0.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,156 kB
  • sloc: python: 10,333; makefile: 7
file content (26 lines) | stat: -rw-r--r-- 842 bytes parent folder | download | duplicates (3)
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
# Copyright 2016-2018 Dirk Thomas
# Licensed under the Apache License, Version 2.0

from unittest.mock import patch

from colcon_core.event.command import Command
from colcon_core.event.command import CommandEnded
from colcon_core.event_handler.log_command import LogCommandEventHandler


def test_console_direct():
    extension = LogCommandEventHandler()

    with patch('colcon_core.event_handler.log_command.logger.debug') as debug:
        event = Command(['executable'], cwd='/some/path')
        extension((event, None))
        assert debug.call_count == 1

        debug.reset_mock()
        event = CommandEnded(['executable'], cwd='/some/path', returncode=1)
        extension((event, None))
        assert debug.call_count == 1

        debug.reset_mock()
        extension(('unknown', None))
        assert debug.call_count == 0