Mercurial > hg > AtomicWrite
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:dc90512b9c98 | 1:a4188f41ca35 |
---|---|
2 | 2 |
3 """ | 3 """ |
4 unit tests for AtomicWrite | 4 unit tests for AtomicWrite |
5 """ | 5 """ |
6 | 6 |
7 import atomic | |
7 import os | 8 import os |
8 import sys | |
9 import tempfile | 9 import tempfile |
10 import unittest | 10 import unittest |
11 | 11 |
12 class AtomicWriteUnitTest(unittest.TestCase): | 12 class AtomicWriteUnitTest(unittest.TestCase): |
13 | 13 |
14 def test_atomicwrite(self): | 14 def test_atomicwrite(self): |
15 tf = tempfile.mktemp() | 15 tf = tempfile.mktemp() |
16 self.assertFalse(os.path.exists(tf)) | 16 self.assertFalse(os.path.exists(tf)) |
17 atomic.write('foo', tf) | |
18 self.assertTrue(os.path.exists(tf)) | |
19 self.assertEqual(open(tf, 'r').read(), 'foo') | |
17 | 20 |
18 if __name__ == '__main__': | 21 if __name__ == '__main__': |
19 unittest.main() | 22 unittest.main() |
20 | 23 |