Coverage for tests / eclipse / care / test_care.py: 100%
28 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-24 09:38 +0100
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-24 09:38 +0100
1# Copyright (c) 2025 The Eclipse Foundation
2#
3# This program and the accompanying materials are made available under the
4# terms of the Eclipse Public License 2.0 which is available at
5# http://www.eclipse.org/legal/epl-2.0.
6#
7# SPDX-License-Identifier: EPL-2.0
9import sys
10import pytest
11from unittest.mock import patch
12from pprint import pprint
14import care as target
16def test_args_help(capsys):
17 # Execute command with some cli parameters
18 # Expect an exit code of 0
19 with patch('sys.argv', ["eclipse-care", "-h"]):
20 with pytest.raises(SystemExit) as e:
21 target.main()
22 assert e.value.code == 0
23 out, err = capsys.readouterr()
24 assert out.startswith('usage:')
26def test_args_version(capsys):
27 # Execute command with some cli parameters
28 # Expect an exit code of 0
29 with patch('sys.argv', ["eclipse-care", "-V"]):
30 with pytest.raises(SystemExit) as e:
31 target.main()
32 assert e.value.code == 0
33 out, err = capsys.readouterr()
34 assert out.startswith('Eclipse CARE')
35 pprint(out)
37def test_args_no_project(capsys):
38 # Execute command with no cli parameters
39 # Expect an exit code of 2
40 with patch('sys.argv', ["eclipse-care"]):
41 with pytest.raises(SystemExit) as e:
42 target.main()
43 assert e.value.code == 2
44 out, err = capsys.readouterr()
45 print(err)
46 assert err.startswith('usage:')