/usr/lib/python2.7/dist-packages/tables/tests/test_utils.py is in python-tables 3.4.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | import sys
try:
from unittest.mock import patch
except ImportError:
from mock import patch
import six
from tables.tests import common
from tables.tests.common import unittest
from tables.tests.common import PyTablesTestCase as TestCase
import tables.scripts.ptrepack as ptrepack
import tables.scripts.ptdump as ptdump
import tables.scripts.pttree as pttree
class ptrepackTestCase(TestCase):
"""Test ptrepack"""
@patch.object(ptrepack, 'copy_leaf')
@patch.object(ptrepack, 'open_file')
def test_paths_windows(self, mock_open_file, mock_copy_leaf):
"""Checking handling of windows filenames: test gh-616"""
# this filename has a semi-colon to check for
# regression of gh-616
src_fn = 'D:\\window~1\\path\\000\\infile'
src_path = '/'
dst_fn = 'another\\path\\'
dst_path = '/path/in/outfile'
argv = ['ptrepack', src_fn + ':' + src_path, dst_fn + ':' + dst_path]
with patch.object(sys, 'argv', argv):
ptrepack.main()
args, kwargs = mock_open_file.call_args_list[0]
self.assertEqual(args, (src_fn, 'r'))
args, kwargs = mock_copy_leaf.call_args_list[0]
self.assertEqual(args, (src_fn, dst_fn, src_path, dst_path))
class ptdumpTestCase(TestCase):
"""Test ptdump"""
@patch.object(ptdump, 'open_file')
@patch('sys.stdout', new_callable=six.StringIO)
def test_paths_windows(self, _, mock_open_file):
"""Checking handling of windows filenames: test gh-616"""
# this filename has a semi-colon to check for
# regression of gh-616 (in ptdump)
src_fn = 'D:\\window~1\\path\\000\\ptdump'
src_path = '/'
argv = ['ptdump', src_fn + ':' + src_path]
with patch.object(sys, 'argv', argv):
ptdump.main()
args, kwargs = mock_open_file.call_args_list[0]
self.assertEqual(args, (src_fn, 'r'))
class pttreeTestCase(TestCase):
"""Test ptdump"""
@patch.object(pttree.tables, 'open_file')
@patch.object(pttree, 'get_tree_str')
@patch('sys.stdout', new_callable=six.StringIO)
def test_paths_windows(self, _, mock_get_tree_str, mock_open_file):
"""Checking handling of windows filenames: test gh-616"""
# this filename has a semi-colon to check for
# regression of gh-616 (in pttree)
src_fn = 'D:\\window~1\\path\\000\\pttree'
src_path = '/'
argv = ['pttree', src_fn + ':' + src_path]
with patch.object(sys, 'argv', argv):
pttree.main()
args, kwargs = mock_open_file.call_args_list[0]
self.assertEqual(args, (src_fn, 'r'))
def suite():
theSuite = unittest.TestSuite()
theSuite.addTest(unittest.makeSuite(ptrepackTestCase))
theSuite.addTest(unittest.makeSuite(ptdumpTestCase))
theSuite.addTest(unittest.makeSuite(pttreeTestCase))
return theSuite
if __name__ == '__main__':
common.parse_argv(sys.argv)
common.print_versions()
unittest.main(defaultTest='suite')
|