Example #1
0
 def test_obj(self):
     o = object()
     with util.maybe_tempfile(o, prefix='tmp') as tf:
         self.assertEqual(o, tf)
Example #2
0
 def test_obj(self):
     o = object()
     with util.maybe_tempfile(o, prefix='tmp') as tf:
         self.assertEqual(o, tf)
Example #3
0
 def test_tempfile(self):
     with util.maybe_tempfile(prefix='tmp') as tf:
         self.assertFalse(tf.closed)
         self.assertTrue(os.path.basename(tf.name).startswith('tmp'))
     self.assertTrue(tf.closed)
     self.assertFalse(os.path.exists(tf.name))
Example #4
0
 def test_tempfile(self):
     with util.maybe_tempfile(prefix='tmp') as tf:
         self.assertFalse(tf.closed)
         self.assertTrue(os.path.basename(tf.name).startswith('tmp'))
     self.assertTrue(tf.closed)
     self.assertFalse(os.path.exists(tf.name))