Debian Codegraph @

python/mozterm/test/test_terminal.py

raw
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4
5 import os
6 import sys
7
8 import mozunit
9 import pytest
10
11 from mozterm import NullTerminal, Terminal
12
13
14 def test_terminal():
15 blessed = pytest.importorskip("blessed")
16 term = Terminal()
17 assert isinstance(term, blessed.Terminal)
18
19 term = Terminal(disable_styling=True)
20 assert isinstance(term, NullTerminal)
21
22
23 def test_null_terminal():
24 term = NullTerminal()
25 assert term.red("foo") == "foo"
26 assert term.red == ""
27 assert term.color(1) == ""
28 assert term.number_of_colors == 0
29 assert term.width == 0
30 assert term.height == 0
31 assert term.is_a_tty == os.isatty(sys.stdout.fileno())
32
33
34 if __name__ == "__main__":
35 mozunit.main()