diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2003-01-28 21:39:28 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2003-01-28 21:39:28 (GMT) |
commit | 10882f6fcb2362969d0094da89edb49d76b1a371 (patch) | |
tree | d6fa217475f3ab8fd5760290c46e53be3a8eeff8 /Lib/test/test_macfs.py | |
parent | fe8d84d5aea0f8ff9c27276473b1b8a1d69f5aeb (diff) | |
download | cpython-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_macfs.py')
-rw-r--r-- | Lib/test/test_macfs.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Lib/test/test_macfs.py b/Lib/test/test_macfs.py new file mode 100644 index 0000000..9c865d5 --- /dev/null +++ b/Lib/test/test_macfs.py @@ -0,0 +1,69 @@ +# Copyright (C) 2003 Python Software Foundation + +import unittest +import macfs +import os +import tempfile +from test import test_support + +class TestMacfs(unittest.TestCase): + + def setUp(self): + fp = open(test_support.TESTFN, 'w') + fp.write('hello world\n') + fp.close() + + def tearDown(self): + try: + os.unlink(test_support.TESTFN) + except: + pass + + def test_fsspec(self): + fss = macfs.FSSpec(test_support.TESTFN) + self.assertEqual(os.path.abspath(test_support.TESTFN), fss.as_pathname()) + + def test_fsref(self): + fsr = macfs.FSRef(test_support.TESTFN) + self.assertEqual(os.path.abspath(test_support.TESTFN), fsr.as_pathname()) + + def test_coercion(self): + fss = macfs.FSSpec(test_support.TESTFN) + fsr = macfs.FSRef(test_support.TESTFN) + fss2 = fsr.as_fsspec() + fsr2 = fss.as_fsref() + self.assertEqual(fss.as_pathname(), fss2.as_pathname()) + self.assertEqual(fsr.as_pathname(), fsr2.as_pathname()) + + def test_dates(self): + import time + fss = macfs.FSSpec(test_support.TESTFN) + now = int(time.time()) + fss.SetDates(now, now-1, now-2) + dates = fss.GetDates() + self.assertEqual(dates, (now, now-1, now-2)) + + def test_ctor_type(self): + fss = macfs.FSSpec(test_support.TESTFN) + fss.SetCreatorType('Pyth', 'TEXT') + filecr, filetp = fss.GetCreatorType() + self.assertEqual((filecr, filetp), ('Pyth', 'TEXT')) + + def test_alias(self): + fss = macfs.FSSpec(test_support.TESTFN) + alias = fss.NewAlias() + fss2, changed = alias.Resolve() + self.assertEqual(changed, 0) + self.assertEqual(fss.as_pathname(), fss2.as_pathname()) + + + def test_fss_alias(self): + fss = macfs.FSSpec(test_support.TESTFN) + + +def test_main(): + test_support.run_unittest(TestMacfs) + + +if __name__ == '__main__': + test_main() |