Debian Codegraph @

tests/pyscript/test_print.py

raw symbols SCIP
1 """
2 This script is used to test the py_print() wrapper that cmd2 provides as a replacement
3 for the built-in print() function in the embedded Python environment.
4 """
5
6 import sys
7
8 from rich.text import Text
9
10 # Test multiple objects and sep
11 print("hello", "world", sep="-")
12
13 # Test end
14 print("no newline", end=" ")
15 print("here")
16
17 # Test multiple objects with custom sep and end
18 print(1, 2, 3, sep=":", end=".")
19 print() # to get a newline
20
21 # Test printing a Rich object
22 text = Text("I am Rich Text", style="blue")
23 print(text)
24
25 # Test file=sys.stdout
26 print("this goes to sys.stdout", file=sys.stdout)
27
28 # Test file=sys.stderr
29 print("this goes to sys.stderr", file=sys.stderr)