Exemplo n.º 1
0
 def test_fileno(self):
     try:
         t1 = writeTmp(1, ["A\nB"])
         t2 = writeTmp(2, ["C\nD"])
         fi = FileInput(files=(t1, t2))
         self.assertEqual(fi.fileno(), -1)
         line = fi.next()
         self.assertNotEqual(fi.fileno(), -1)
         fi.nextfile()
         self.assertEqual(fi.fileno(), -1)
         line = list(fi)
         self.assertEqual(fi.fileno(), -1)
     finally:
         remove_tempfiles(t1, t2)
Exemplo n.º 2
0
 def test_fileno(self):
     try:
         t1 = writeTmp(1, ["A\nB"])
         t2 = writeTmp(2, ["C\nD"])
         fi = FileInput(files=(t1, t2))
         self.assertEqual(fi.fileno(), -1)
         line = fi.next()
         self.assertNotEqual(fi.fileno(), -1)
         fi.nextfile()
         self.assertEqual(fi.fileno(), -1)
         line = list(fi)
         self.assertEqual(fi.fileno(), -1)
     finally:
         remove_tempfiles(t1, t2)
Exemplo n.º 3
0
    if encoding is None:
        encoding = 'ascii'
    fi = FileInput(files=unicode(t1, encoding))
    lines = list(fi)
    verify(lines == ["A\n", "B"])
finally:
    remove_tempfiles(t1)

if verbose:
    print "16. fileno()"
try:
    t1 = writeTmp(1, ["A\nB"])
    t2 = writeTmp(2, ["C\nD"])
    fi = FileInput(files=(t1, t2))
    verify(fi.fileno() == -1)
    line = fi.next()
    verify(fi.fileno() != -1)
    fi.nextfile()
    verify(fi.fileno() == -1)
    line = list(fi)
    verify(fi.fileno() == -1)
finally:
    remove_tempfiles(t1, t2)

if verbose:
    print "17. Specify opening mode"
try:
    # invalid mode, should raise ValueError
    fi = FileInput(mode="w")
    raise TestFailed("FileInput should reject invalid mode argument")
except ValueError:
Exemplo n.º 4
0
    if encoding is None:
        encoding = 'ascii'
    fi = FileInput(files=unicode(t1, encoding))
    lines = list(fi)
    verify(lines == ["A\n", "B"])
finally:
    remove_tempfiles(t1)

if verbose:
    print "16. fileno()"
try:
    t1 = writeTmp(1, ["A\nB"])
    t2 = writeTmp(2, ["C\nD"])
    fi = FileInput(files=(t1, t2))
    verify(fi.fileno() == -1)
    line = fi.next()
    verify(fi.fileno() != -1)
    fi.nextfile()
    verify(fi.fileno() == -1)
    line = list(fi)
    verify(fi.fileno() == -1)
finally:
    remove_tempfiles(t1, t2)

if verbose:
    print "17. Specify opening mode"
try:
    # invalid mode, should raise ValueError
    fi = FileInput(mode="w")
    raise TestFailed("FileInput should reject invalid mode argument")
except ValueError: