File: test_testing.py

package info (click to toggle)
python-consolekit 1.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,152 kB
  • sloc: python: 2,835; makefile: 8
file content (46 lines) | stat: -rw-r--r-- 1,094 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 3rd party
import click

# this package
from consolekit import click_command
from consolekit.options import DescribedArgument
from consolekit.testing import CliRunner


def test_result(cli_runner: CliRunner):

	@click.argument(
			"dest",
			cls=DescribedArgument,
			type=click.STRING,
			description="The destination directory.",
			)
	@click_command()
	def main(dest: str) -> None:
		print(dest)

	result = cli_runner.invoke(main, catch_exceptions=False, args="./staging")
	assert result.stdout.rstrip() == "./staging"
	assert result.output.rstrip() == "./staging"
	assert result.exit_code == 0


def test_result_no_mix_stderr():

	cli_runner = CliRunner(mix_stderr=False)

	@click.argument(
			"dest",
			cls=DescribedArgument,
			type=click.STRING,
			description="The destination directory.",
			)
	@click_command()
	def main(dest: str) -> None:
		print(dest)

	result = cli_runner.invoke(main, catch_exceptions=False, args="./staging")
	assert result.stdout.rstrip() == "./staging"
	assert result.stderr == ''
	assert result.output.rstrip() == "./staging"
	assert result.exit_code == 0