annotate tests/test_atomicwrite.py @ 1:a4188f41ca35 default tip

basically the thing
author Jeff Hammel <k0scist@gmail.com>
date Fri, 02 Jan 2015 13:22:09 -0800
parents dc90512b9c98
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 unit tests for AtomicWrite
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 """
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
1
a4188f41ca35 basically the thing
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
7 import atomic
0
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import os
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 import tempfile
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import unittest
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 class AtomicWriteUnitTest(unittest.TestCase):
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def test_atomicwrite(self):
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 tf = tempfile.mktemp()
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 self.assertFalse(os.path.exists(tf))
1
a4188f41ca35 basically the thing
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
17 atomic.write('foo', tf)
a4188f41ca35 basically the thing
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
18 self.assertTrue(os.path.exists(tf))
a4188f41ca35 basically the thing
Jeff Hammel <k0scist@gmail.com>
parents: 0
diff changeset
19 self.assertEqual(open(tf, 'r').read(), 'foo')
0
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 if __name__ == '__main__':
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 unittest.main()
dc90512b9c98 boilerplate
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23