Debian Codegraph @

autopage/tests/test_line_buffer_from_input.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
12
13 import unittest
14
15 import fixtures # type: ignore
16
17 from autopage.tests import sinks
18
19 import autopage
20
21
22 class LineBufferFromInputTest(unittest.TestCase):
23 def test_tty(self) -> None:
24 with sinks.TTYFixture() as inp:
25 self.assertTrue(autopage.line_buffer_from_input(inp.stream))
26
27 def test_file(self) -> None:
28 with sinks.TempFixture() as inp:
29 self.assertFalse(autopage.line_buffer_from_input(inp.stream))
30
31 def test_default_tty(self) -> None:
32 with sinks.TTYFixture() as inp:
33 with fixtures.MonkeyPatch('sys.stdin', inp.stream):
34 self.assertTrue(autopage.line_buffer_from_input())
35
36 def test_default_file(self) -> None:
37 with sinks.TempFixture() as inp:
38 with fixtures.MonkeyPatch('sys.stdin', inp.stream):
39 self.assertFalse(autopage.line_buffer_from_input())