File: test_ls_tree.rst

package info (click to toggle)
nose 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,208 kB
  • ctags: 2,517
  • sloc: python: 13,200; makefile: 80; sh: 2
file content (50 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download | duplicates (10)
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
    >>> import os
    >>> import tempfile
    >>> import shutil

    >>> from nose.util import ls_tree

    >>> dir_path = tempfile.mkdtemp()

    >>> def create_file(filename):
    ...     fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0666)
    ...     os.close(fd)

    >>> os.mkdir(os.path.join(dir_path, "top"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir2"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir3"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir/dir"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir/dir2"))
    >>> os.mkdir(os.path.join(dir_path, "top/.svn"))
    >>> os.mkdir(os.path.join(dir_path, "top/.notsvn"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir/.svn"))
    >>> os.mkdir(os.path.join(dir_path, "top/dir/.notsvn"))
    >>> create_file(os.path.join(dir_path, "top/file"))
    >>> create_file(os.path.join(dir_path, "top/backup_file~"))
    >>> create_file(os.path.join(dir_path, "top/file2"))
    >>> create_file(os.path.join(dir_path, "top/dir/file"))
    >>> create_file(os.path.join(dir_path, "top/dir/dir/file"))
    >>> create_file(os.path.join(dir_path, "top/dir/dir/file2"))
    >>> create_file(os.path.join(dir_path, "top/dir/backup_file~"))
    >>> create_file(os.path.join(dir_path, "top/dir2/file"))

    Note that files matching skip_pattern (by default SVN files,
    backup files and compiled Python files) are ignored

    >>> print ls_tree(os.path.join(dir_path, "top"))
    |-- file
    |-- file2
    |-- .notsvn
    |-- dir
    |   |-- file
    |   |-- .notsvn
    |   |-- dir
    |   |   |-- file
    |   |   `-- file2
    |   `-- dir2
    |-- dir2
    |   `-- file
    `-- dir3

    >>> shutil.rmtree(dir_path)