Beispiel #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"])
 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"])
Beispiel #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)
 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)
Beispiel #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)
Beispiel #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])
Beispiel #7
0
 def test_write(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom(b"P"), "data"), stdout.write("data"))
     self.assertRaises(TypeError, stdout.write, 1234)
 def test_writelines(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom("P"), "data"), stdout.writelines(["da", "ta"]))
     self.assertRaises(TypeError, stdout.writelines, ["da", 1234])
 def test_write(self):
     stdout = RedirectedStdout(TestPort())
     self.assertEqual((Atom("P"), "data"), stdout.write("data"))
     self.assertRaises(TypeError, stdout.write, 1234)
Beispiel #10
0
 def test_unsupported_methods(self):
     stdout = RedirectedStdout(TestPort())
     self.assertRaises(RuntimeError, stdout.read)