File: test_nt_paths_jy.py

package info (click to toggle)
jython 2.5.3-16%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 43,772 kB
  • ctags: 106,434
  • sloc: python: 351,322; java: 216,349; xml: 1,584; sh: 330; perl: 114; ansic: 102; makefile: 45
file content (40 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""Test path handling on Windows

Made for Jython.
"""
from __future__ import with_statement
import os
import unittest
from test import test_support

class NTAbspathTestCase(unittest.TestCase):

    def setUp(self):
        with open(test_support.TESTFN, 'w') as fp:
            fp.write('foo')

        # Move to the same drive as TESTFN
        drive, self.path = os.path.splitdrive(os.path.abspath(
                test_support.TESTFN))
        self.orig_cwd = os.getcwd()
        os.chdir(os.path.join(drive, os.sep))

    def tearDown(self):
        os.chdir(self.orig_cwd)
        os.remove(test_support.TESTFN)

    def test_abspaths(self):
        # Ensure r'\TESTFN' and '/TESTFN' are handled as absolute
        for path in self.path, self.path.replace('\\', '/'):
            with open(path) as fp:
                self.assertEqual(fp.read(), 'foo')


def test_main():
    if (os._name if test_support.is_jython else os.name) != 'nt':
        raise test_support.TestSkipped('NT specific test')
    test_support.run_unittest(NTAbspathTestCase)


if __name__ == '__main__':
    test_main()