Пример #1
0
 def test14_write(self):
     """Test write method."""
     tempdir = tempfile.mkdtemp(prefix='test_namaste')
     n = Namaste(0, 'balloon')
     n.write(tempdir)
     filepath = os.path.join(tempdir, '0=balloon')
     self.assertTrue(os.path.isfile(filepath))
     with open(filepath, 'r') as fh:
         self.assertEqual(fh.read(), 'balloon\n')
Пример #2
0
 def test14_write(self):
     """Test write method."""
     tempdir = tempfile.mkdtemp(prefix='test_namaste')
     # Plain OS method
     n = Namaste(0, 'balloon')
     n.write(tempdir)
     filepath = os.path.join(tempdir, '0=balloon')
     self.assertTrue(os.path.isfile(filepath))
     with open(filepath, 'r', encoding="utf-8") as fh:
         self.assertEqual(fh.read(), 'balloon\n')
     # With fs filesystem
     tmpfs = fs.tempfs.TempFS()
     n = Namaste(1, 'jelly')
     n.write(pyfs=tmpfs)
     self.assertTrue(tmpfs.isfile('1=jelly'))
     self.assertEqual(tmpfs.readtext('1=jelly'), 'jelly\n')