Пример #1
0
 def test_readline(self):
     "Should ducktype as a file and readline()"
     nopath = tempfile.mkdtemp()
     p = Path(nopath) + 'testfile.txt'
     p << "Frist\nNext\nLast"
     self.assertEqual("Frist\n", p.readline())
     self.assertEqual("Next\n", p.readline())
     self.assertEqual("Last", p.readline())
     self.assertEqual("", p.readline())
Пример #2
0
 def test_readline(self):
     "Should ducktype as a file and readline()"
     nopath = tempfile.mkdtemp()
     p = Path(nopath) + 'testfile.txt'
     p << "Frist\nNext\nLast"
     self.assertEqual("Frist\n", p.readline())
     self.assertEqual("Next\n", p.readline())
     self.assertEqual("Last", p.readline())
     self.assertEqual("", p.readline())
Пример #3
0
 def test_readline_nofile(self):
     "Should raise"
     p = Path(tempfile.mktemp())
     with self.assertRaises(TypeError):
         p.readline()
Пример #4
0
 def test_readline_dir(self):
     "Should raise"
     p = Path(self.tdir)
     with self.assertRaises(TypeError):
         p.readline()
Пример #5
0
 def test_readline_nofile(self):
     "Should raise"
     p = Path(tempfile.mktemp())
     with self.assertRaises(TypeError):
         p.readline()
Пример #6
0
 def test_readline_dir(self):
     "Should raise"
     p = Path(self.tdir)
     with self.assertRaises(TypeError):
         p.readline()