summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_macostools.py
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2003-01-28 21:39:28 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2003-01-28 21:39:28 (GMT)
commit10882f6fcb2362969d0094da89edb49d76b1a371 (patch)
treed6fa217475f3ab8fd5760290c46e53be3a8eeff8 /Lib/test/test_macostools.py
parentfe8d84d5aea0f8ff9c27276473b1b8a1d69f5aeb (diff)
downloadcpython-10882f6fcb2362969d0094da89edb49d76b1a371.zip
cpython-10882f6fcb2362969d0094da89edb49d76b1a371.tar.gz
cpython-10882f6fcb2362969d0094da89edb49d76b1a371.tar.bz2
Finally created the first two tests for MacPython modules: macfs and
macostools.
Diffstat (limited to 'Lib/test/test_macostools.py')
-rw-r--r--Lib/test/test_macostools.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/Lib/test/test_macostools.py b/Lib/test/test_macostools.py
new file mode 100644
index 0000000..55ca1b2
--- /dev/null
+++ b/Lib/test/test_macostools.py
@@ -0,0 +1,69 @@
+# Copyright (C) 2003 Python Software Foundation
+
+import unittest
+import macostools
+import MacOS
+import os
+import tempfile
+from test import test_support
+
+TESTFN2 = test_support.TESTFN + '2'
+
+class TestMacostools(unittest.TestCase):
+
+ def setUp(self):
+ fp = open(test_support.TESTFN, 'w')
+ fp.write('hello world\n')
+ fp.close()
+ rfp = MacOS.openrf(test_support.TESTFN, '*wb')
+ rfp.write('goodbye world\n')
+ rfp.close()
+
+ def tearDown(self):
+ try:
+ os.unlink(test_support.TESTFN)
+ except:
+ pass
+ try:
+ os.unlink(TESTFN2)
+ except:
+ pass
+
+ def compareData(self):
+ fp = open(test_support.TESTFN, 'r')
+ data1 = fp.read()
+ fp.close()
+ fp = open(TESTFN2, 'r')
+ data2 = fp.read()
+ fp.close()
+ if data1 != data2:
+ return 'Data forks differ'
+ rfp = MacOS.openrf(test_support.TESTFN, '*rb')
+ data1 = rfp.read(1000)
+ rfp.close()
+ rfp = MacOS.openrf(TESTFN2, '*rb')
+ data2 = rfp.read(1000)
+ rfp.close()
+ if data1 != data2:
+ return 'Resource forks differ'
+ return ''
+
+ def test_touched(self):
+ # This really only tests that nothing unforeseen happens.
+ macostools.touched(test_support.TESTFN)
+
+ def test_copy(self):
+ try:
+ os.unlink(TESTFN2)
+ except:
+ pass
+ macostools.copy(test_support.TESTFN, TESTFN2)
+ self.assertEqual(self.compareData(), '')
+
+
+def test_main():
+ test_support.run_unittest(TestMacostools)
+
+
+if __name__ == '__main__':
+ test_main()