Ejemplo n.º 1
0
 def test_close(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual(False, stdout.closed)
     self.assertEqual(None, stdout.close())
     self.assertEqual(True, stdout.closed)
     self.assertEqual(None, stdout.close())
     self.assertRaises(ValueError, stdout.write, "data")
     self.assertRaises(ValueError, stdout.writelines, ["da", "ta"])
Ejemplo n.º 2
0
 def test_close(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual(False, stdout.closed)
     self.assertEqual(None, stdout.close())
     self.assertEqual(True, stdout.closed)
     self.assertEqual(None, stdout.close())
     self.assertRaises(ValueError, stdout.write, "data")
     self.assertRaises(ValueError, stdout.writelines, ["da", "ta"])
Ejemplo n.º 3
0
 def test_methods(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual(1, stdout.fileno())
     self.assertEqual(True, stdout.isatty())
     self.assertEqual(None, stdout.flush())
     self.assertRaises(IOError, stdout.next)
     self.assertRaises(IOError, stdout.read)
     self.assertRaises(IOError, stdout.readline)
     self.assertRaises(IOError, stdout.readlines)
     self.assertRaises(IOError, stdout.xreadlines)
     self.assertRaises(IOError, stdout.seek, 0)
     self.assertRaises(IOError, stdout.tell)
     self.assertRaises(IOError, stdout.truncate)
Ejemplo n.º 4
0
 def test_methods(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual(1, stdout.fileno())
     self.assertEqual(True, stdout.isatty())
     self.assertEqual(None, stdout.flush())
     self.assertRaises(IOError, stdout.next)
     self.assertRaises(IOError, stdout.read)
     self.assertRaises(IOError, stdout.readline)
     self.assertRaises(IOError, stdout.readlines)
     self.assertRaises(IOError, stdout.xreadlines)
     self.assertRaises(IOError, stdout.seek, 0)
     self.assertRaises(IOError, stdout.tell)
     self.assertRaises(IOError, stdout.truncate)
Ejemplo n.º 5
0
 def test_attributes(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual(False, stdout.closed)
     self.assertEqual("UTF-8", stdout.encoding)
     self.assertEqual(None, stdout.errors)
     self.assertEqual("w", stdout.mode)
     self.assertEqual("<stdout>", stdout.name)
     self.assertEqual(None, stdout.newlines)
Ejemplo n.º 6
0
 def test_writelines(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom(b"P"), "data"), stdout.writelines(["da", "ta"]))
     self.assertRaises(TypeError, stdout.writelines, ["da", 1234])
Ejemplo n.º 7
0
 def test_write(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom(b"P"), "data"), stdout.write("data"))
     self.assertRaises(TypeError, stdout.write, 1234)
Ejemplo n.º 8
0
 def test_writelines(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom("P"), "data"), stdout.writelines(["da", "ta"]))
     self.assertRaises(TypeError, stdout.writelines, ["da", 1234])
Ejemplo n.º 9
0
 def test_write(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom("P"), "data"), stdout.write("data"))
     self.assertRaises(TypeError, stdout.write, 1234)
Ejemplo n.º 10
0
 def test_unsupported_methods(self):
     stdout = RedirectedStdout(TestPort())
     self.assertRaises(RuntimeError, stdout.read)