0
|
1 #!/usr/bin/env python
|
|
2
|
|
3 """
|
|
4 unit tests for AtomicWrite
|
|
5 """
|
|
6
|
1
|
7 import atomic
|
0
|
8 import os
|
|
9 import tempfile
|
|
10 import unittest
|
|
11
|
|
12 class AtomicWriteUnitTest(unittest.TestCase):
|
|
13
|
|
14 def test_atomicwrite(self):
|
|
15 tf = tempfile.mktemp()
|
|
16 self.assertFalse(os.path.exists(tf))
|
1
|
17 atomic.write('foo', tf)
|
|
18 self.assertTrue(os.path.exists(tf))
|
|
19 self.assertEqual(open(tf, 'r').read(), 'foo')
|
0
|
20
|
|
21 if __name__ == '__main__':
|
|
22 unittest.main()
|
|
23
|