Esempio n. 1
0
def test_mutual_one_file_no_roots(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, with no valid roots.
    """
    _, tmpdir = mutual_one_file
    tree = FSTree.at_path(os.path.join(tmpdir, 'a'), set())
    assert tree == FSTree({})
Esempio n. 2
0
def test_mutual_one_file_first_root_valid(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the tree
    the file is actually in is not a valid root.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {root})
    assert tree == FSTree({})
Esempio n. 3
0
def test_basic_ignore_dir(basic):
    """Test ignoring some directory (which appears twice)."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('a/'))
    # Causes 'h' to go too since it's now empty
    assert tree == FSTree({
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 4
0
def test_mutual_one_file_second_root_valid(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the tree we
    ask to query is not a valid root.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    other = os.path.join(tmpdir, 'd')
    tree = FSTree.at_path(root, {other})
    assert tree == FSTree({})
Esempio n. 5
0
def test_basic_ignore_top_level_dir(basic):
    """Test ignoring some directory at the top level only."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('/a/'))
    assert tree == FSTree({
        'h': FSTree({'a': FSTree({
            'i': None,
        })}),
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 6
0
def test_filter_dir_path_link_resolved(with_suffixes):
    """
    Test that matching vs a folder we linked to doesn't work.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Here zoom is not in our tree at all (as fred links to it); even though
    # it's part of the absolute name of some files, we're only matching vs
    # names in the tree, from which this name is pruned because fred already
    # got there.
    prefix = re.compile('^.*zoom.*$')
    filtered = tree.filter([prefix])
    assert filtered == FSTree({})
Esempio n. 7
0
def test_basic_ignore_several(basic):
    """Test ignoring several names."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('b', 'h', 'j'))
    assert tree == FSTree({
        'a':
        FSTree({
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
    })
Esempio n. 8
0
def test_basic_subtree(basic):
    """Test subtree of basic tree with not much drama."""
    _, tmpdir = basic
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {root})
    # Note no entry for 'a/g' - it's an empty folder
    assert tree == FSTree({
        'b': None,
        'a': FSTree({
            'd': None,
            'e': None,
        }),
        'f': None,
    })
Esempio n. 9
0
def test_filter_many(basic):
    """
    Test using multiple filters.
    """
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter(
        [re.compile(p) for p in ('.*a$', '.*(d|i)$', '.*e$')]
    )
    assert filtered == FSTree({
        'a': FSTree({
            'a': FSTree({
                'd': None,
                'e': None,
            }),
        }),
        'h': FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 10
0
def test_filter_one(basic):
    """
    Test using a single filter.

    This test keeps matching files (but not matching directories),
    and that folders which are empty after filtering after filtered too.

    """
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([re.compile('.*a$')])
    assert filtered == FSTree({
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 11
0
def test_basic(basic):
    """Test basic tree with not much drama."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Note no entry for 'a/g' - it's an empty folder
    jib = FSTree({
        'a': FSTree({
            'b': None,
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
        'h': FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j': FSTree({
            'a': None,
        }),
    })

    assert tree == jib
Esempio n. 12
0
def test_mutual_one_file_no_roots(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, with no valid roots.
    """
    _, tmpdir = mutual_one_file
    tree = FSTree.at_path(os.path.join(tmpdir, 'a'), set())
    assert tree == FSTree({})
Esempio n. 13
0
def test_filter_on_path(with_suffixes):
    """
    Test that filters can consider paths or path fragments.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # A pattern specifying a full path to a file
    full = re.compile('^foo/moo/zoo/BAR.md$')
    # A pattern specifying a file prefix, i.e. a path to a directory.
    prefix = re.compile('^fred.*$')
    filtered = tree.filter([full, prefix])
    assert filtered == FSTree({
        'foo': FSTree({
            'moo': FSTree({
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
        'fred': FSTree({
            'blah.txt': None,
            'klang.rst': None,
            'wuub': None,
        }),
    })
Esempio n. 14
0
def test_triple_linked_all_valid(triple_linked):
    """
    Test linking across three trees, where all three are valid roots.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    second = os.path.join(tmpdir, 'd')
    third = os.path.join(tmpdir, 'g')
    tree = FSTree.at_path(first, {first, second, third})
    assert tree == FSTree({
        'b':
        FSTree({
            'c':
            FSTree({
                'e':
                FSTree({
                    'f': FSTree({
                        'h': FSTree({
                            'i': None,
                        }),
                    }),
                }),
            }),
        }),
    })
Esempio n. 15
0
def test_basic(basic):
    """Test basic tree with not much drama."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Note no entry for 'a/g' - it's an empty folder
    jib = FSTree({
        'a':
        FSTree({
            'b': None,
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
        'h':
        FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j':
        FSTree({
            'a': None,
        }),
    })

    assert tree == jib
Esempio n. 16
0
def test_filter_many(basic):
    """
    Test using multiple filters.
    """
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter(
        [re.compile(p) for p in ('.*a$', '.*(d|i)$', '.*e$')])
    assert filtered == FSTree({
        'a':
        FSTree({
            'a': FSTree({
                'd': None,
                'e': None,
            }),
        }),
        'h':
        FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j':
        FSTree({
            'a': None,
        }),
    })
Esempio n. 17
0
def test_filter_empty(basic):
    """Test an empty filter list."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([])
    assert filtered == FSTree({
        'a':
        FSTree({
            'b': None,
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
        'h':
        FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j':
        FSTree({
            'a': None,
        }),
    })
Esempio n. 18
0
def test_mutual_one_file_first_root_valid(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the tree
    the file is actually in is not a valid root.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {root})
    assert tree == FSTree({})
Esempio n. 19
0
def test_filter_suffix_md(with_suffixes):
    """
    Test filtering on *.md
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([re.compile(r'.*\.md$')])
    assert filtered == FSTree({
        'foo':
        FSTree({
            'bar.md': None,
            'moo': FSTree({
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
    })
Esempio n. 20
0
def test_mutual_one_file_both_valid_roots(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where both trees
    are valid roots.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    other = os.path.join(tmpdir, 'd')
    tree = FSTree.at_path(root, {root, other})
    assert tree == FSTree({
        'b':
        FSTree({
            'c': FSTree({
                'e': FSTree({
                    'g': None,
                }),
            }),
        }),
    })
Esempio n. 21
0
def test_mutual_one_file_parent_valid_root(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the parent
    is valid.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {tmpdir})
    # Same result as before: valid parent implies valid children
    assert tree == FSTree({
        'b':
        FSTree({
            'c': FSTree({
                'e': FSTree({
                    'g': None,
                }),
            }),
        }),
    })
Esempio n. 22
0
def test_triple_linked_invalids(triple_linked):
    """
    Test linking across three trees, where 0-2 of of them are not valid roots.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    second = os.path.join(tmpdir, 'd')
    third = os.path.join(tmpdir, 'g')
    for nope in (
            set(),
        {first},
        {second},
        {third},
        {first, second},
        {first, third},
        {second, third},
    ):
        tree = FSTree.at_path(first, valid_roots=nope)
        assert tree == FSTree({})
Esempio n. 23
0
def dict_undict_loops(dict_for_tree):
    """
    Given a dict suitable for FSTree.undict(), put it through a couple of
    cycles.
    """
    # First check undict/dict loop
    tree = FSTree.undict(dict_for_tree)
    dict_from_tree = tree.dict
    assert dict_from_tree == dict_for_tree
    # Then check dict/undict loop
    fixpoint = FSTree.undict(dict_from_tree)
    assert fixpoint == tree
    # Then check to_json/from_json loop
    json_from_tree = tree.to_json()
    tree_from_json = FSTree.from_json(json_from_tree)
    assert tree_from_json == tree
    # Finally check from_json/to_json loop
    json_fixpoint = tree_from_json.to_json()
    assert json_fixpoint == json_from_tree
def dict_undict_loops(dict_for_tree):
    """
    Given a dict suitable for FSTree.undict(), put it through a couple of
    cycles.
    """
    # First check undict/dict loop
    tree = FSTree.undict(dict_for_tree)
    dict_from_tree = tree.dict
    assert dict_from_tree == dict_for_tree
    # Then check dict/undict loop
    fixpoint = FSTree.undict(dict_from_tree)
    assert fixpoint == tree
    # Then check to_json/from_json loop
    json_from_tree = tree.to_json()
    tree_from_json = FSTree.from_json(json_from_tree)
    assert tree_from_json == tree
    # Finally check from_json/to_json loop
    json_fixpoint = tree_from_json.to_json()
    assert json_fixpoint == json_from_tree
Esempio n. 25
0
def test_basic_ignore_dir(basic):
    """Test ignoring some directory (which appears twice)."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('a/'))
    # Causes 'h' to go too since it's now empty
    assert tree == FSTree({
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 26
0
def test_mutual_one_file_second_root_valid(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the tree we
    ask to query is not a valid root.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    other = os.path.join(tmpdir, 'd')
    tree = FSTree.at_path(root, {other})
    assert tree == FSTree({})
Esempio n. 27
0
def test_filter_on_path(with_suffixes):
    """
    Test that filters can consider paths or path fragments.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # A pattern specifying a full path to a file
    full = re.compile('^foo/moo/zoo/BAR.md$')
    # A pattern specifying a file prefix, i.e. a path to a directory.
    prefix = re.compile('^fred.*$')
    filtered = tree.filter([full, prefix])
    assert filtered == FSTree({
        'foo':
        FSTree({
            'moo': FSTree({
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
        'fred':
        FSTree({
            'blah.txt': None,
            'klang.rst': None,
            'wuub': None,
        }),
    })
Esempio n. 28
0
def test_filter_suffices_case_insens(with_suffixes):
    """
    Test the kind of filter we're really going to want to do.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    md_insens = re.compile(r'.*\.md$', re.IGNORECASE)
    rst_insens = re.compile(r'.*\.rst$', re.IGNORECASE)
    filtered = tree.filter([md_insens, rst_insens])
    assert filtered == FSTree({
        'foo':
        FSTree({
            'bar.md':
            None,
            'moo':
            FSTree({
                'BAR.MD': None,
                'zoo': FSTree({
                    'BAR.md': None,
                    'BAR.RST': None,
                }),
            }),
        }),
        'fred':
        FSTree({'klang.rst': None}),
    })
Esempio n. 29
0
def test_foobar(with_suffixes):
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    assert tree == FSTree({
        'foo':
        FSTree({
            'bar.md':
            None,
            'moo':
            FSTree({
                'BAR.MD': None,
                'thing': None,
                'zoo': FSTree({
                    'BAR.md': None,
                    'BAR.RST': None,
                }),
            }),
        }),
        'fred':
        FSTree({
            'blah.txt': None,
            'klang.rst': None,
            'wuub': None,
        }),
    })
Esempio n. 30
0
def test_filter_dir_path_link_resolved(with_suffixes):
    """
    Test that matching vs a folder we linked to doesn't work.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Here zoom is not in our tree at all (as fred links to it); even though
    # it's part of the absolute name of some files, we're only matching vs
    # names in the tree, from which this name is pruned because fred already
    # got there.
    prefix = re.compile('^.*zoom.*$')
    filtered = tree.filter([prefix])
    assert filtered == FSTree({})
Esempio n. 31
0
def test_filter_suffix_md_case_insens(with_suffixes):
    """
    Case insensitive version of test_filter_suffix_md
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    md_insens = re.compile(r'.*\.md$', re.IGNORECASE)
    filtered = tree.filter([md_insens])
    assert filtered == FSTree({
        'foo':
        FSTree({
            'bar.md':
            None,
            'moo':
            FSTree({
                'BAR.MD': None,
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
    })
Esempio n. 32
0
def test_basic_ignore_several(basic):
    """Test ignoring several names."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('b', 'h', 'j'))
    assert tree == FSTree({
        'a': FSTree({
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
    })
Esempio n. 33
0
def test_basic_subtree(basic):
    """Test subtree of basic tree with not much drama."""
    _, tmpdir = basic
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {root})
    # Note no entry for 'a/g' - it's an empty folder
    assert tree == FSTree({
        'b': None,
        'a': FSTree({
            'd': None,
            'e': None,
        }),
        'f': None,
    })
Esempio n. 34
0
def test_basic_ignore_top_level_dir(basic):
    """Test ignoring some directory at the top level only."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('/a/'))
    assert tree == FSTree({
        'h': FSTree({
            'a': FSTree({
                'i': None,
            })
        }),
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 35
0
def test_filter_one(basic):
    """
    Test using a single filter.

    This test keeps matching files (but not matching directories),
    and that folders which are empty after filtering after filtered too.

    """
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([re.compile('.*a$')])
    assert filtered == FSTree({
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 36
0
def test_filter_suffix_md(with_suffixes):
    """
    Test filtering on *.md
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([re.compile(r'.*\.md$')])
    assert filtered == FSTree({
        'foo': FSTree({
            'bar.md': None,
            'moo': FSTree({
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
    })
Esempio n. 37
0
def test_mutual_one_file_parent_valid_root(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the parent
    is valid.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(root, {tmpdir})
    # Same result as before: valid parent implies valid children
    assert tree == FSTree({
        'b': FSTree({
            'c': FSTree({
                'e': FSTree({
                    'g': None,
                }),
            }),
        }),
    })
Esempio n. 38
0
def test_mutual_one_file_both_valid_roots(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where both trees
    are valid roots.
    """
    _, tmpdir = mutual_one_file
    root = os.path.join(tmpdir, 'a')
    other = os.path.join(tmpdir, 'd')
    tree = FSTree.at_path(root, {root, other})
    assert tree == FSTree({
        'b': FSTree({
            'c': FSTree({
                'e': FSTree({
                    'g': None,
                }),
            }),
        }),
    })
Esempio n. 39
0
def test_filter_suffix_md_case_insens(with_suffixes):
    """
    Case insensitive version of test_filter_suffix_md
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    md_insens = re.compile(r'.*\.md$', re.IGNORECASE)
    filtered = tree.filter([md_insens])
    assert filtered == FSTree({
        'foo': FSTree({
            'bar.md': None,
            'moo': FSTree({
                'BAR.MD': None,
                'zoo': FSTree({
                    'BAR.md': None,
                }),
            }),
        }),
    })
Esempio n. 40
0
def test_triple_linked_invalids(triple_linked):
    """
    Test linking across three trees, where 0-2 of of them are not valid roots.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    second = os.path.join(tmpdir, 'd')
    third = os.path.join(tmpdir, 'g')
    for nope in (
        set(),
        {first},
        {second},
        {third},
        {first, second},
        {first, third},
        {second, third},
    ):
        tree = FSTree.at_path(first, valid_roots=nope)
        assert tree == FSTree({})
Esempio n. 41
0
def test_mutual_one_file_parent_valid_root_start_root(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the parent
    is valid, starting at the parent.
    """
    _, tmpdir = mutual_one_file
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Same result as before, but with the extra layer of 'a'; no top-level
    # 'd' folder because we already found it while recursing into 'a'.
    assert tree == FSTree({
        'a': FSTree({
            'b': FSTree({
                'c': FSTree({
                    'e': FSTree({
                        'g': None,
                    }),
                }),
            }),
        }),
    })
Esempio n. 42
0
def test_triple_linked_parent_valid(triple_linked):
    """
    Test linking across three trees, where their parent is a valid root.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(first, {tmpdir})
    assert tree == FSTree({
        'b': FSTree({
            'c': FSTree({
                'e': FSTree({
                    'f': FSTree({
                        'h': FSTree({
                            'i': None,
                        }),
                    }),
                }),
            }),
        }),
    })
Esempio n. 43
0
def test_foobar(with_suffixes):
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    assert tree == FSTree({
        'foo': FSTree({
            'bar.md': None,
            'moo': FSTree({
                'BAR.MD': None,
                'thing': None,
                'zoo': FSTree({
                    'BAR.md': None,
                    'BAR.RST': None,
                }),
            }),
        }),
        'fred': FSTree({
            'blah.txt': None,
            'klang.rst': None,
            'wuub': None,
        }),
    })
Esempio n. 44
0
def test_triple_linked_all_valid(triple_linked):
    """
    Test linking across three trees, where all three are valid roots.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    second = os.path.join(tmpdir, 'd')
    third = os.path.join(tmpdir, 'g')
    tree = FSTree.at_path(first, {first, second, third})
    assert tree == FSTree({
        'b': FSTree({
            'c': FSTree({
                'e': FSTree({
                    'f': FSTree({
                        'h': FSTree({
                            'i': None,
                        }),
                    }),
                }),
            }),
        }),
    })
Esempio n. 45
0
def test_filter_empty(basic):
    """Test an empty filter list."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir})
    filtered = tree.filter([])
    assert filtered == FSTree({
        'a': FSTree({
            'b': None,
            'a': FSTree({
                'd': None,
                'e': None,
            }),
            'f': None,
        }),
        'h': FSTree({
            'a': FSTree({
                'i': None,
            }),
        }),
        'j': FSTree({
            'a': None,
        }),
    })
Esempio n. 46
0
def test_filter_suffices_case_insens(with_suffixes):
    """
    Test the kind of filter we're really going to want to do.
    """
    _, tmpdir = with_suffixes
    tree = FSTree.at_path(tmpdir, {tmpdir})
    md_insens = re.compile(r'.*\.md$', re.IGNORECASE)
    rst_insens = re.compile(r'.*\.rst$', re.IGNORECASE)
    filtered = tree.filter([md_insens, rst_insens])
    assert filtered == FSTree({
        'foo': FSTree({
            'bar.md': None,
            'moo': FSTree({
                'BAR.MD': None,
                'zoo': FSTree({
                    'BAR.md': None,
                    'BAR.RST': None,
                }),
            }),
        }),
        'fred': FSTree({
            'klang.rst': None
        }),
    })
Esempio n. 47
0
def test_triple_linked_parent_valid(triple_linked):
    """
    Test linking across three trees, where their parent is a valid root.
    """
    _, tmpdir = triple_linked
    first = os.path.join(tmpdir, 'a')
    tree = FSTree.at_path(first, {tmpdir})
    assert tree == FSTree({
        'b':
        FSTree({
            'c':
            FSTree({
                'e':
                FSTree({
                    'f': FSTree({
                        'h': FSTree({
                            'i': None,
                        }),
                    }),
                }),
            }),
        }),
    })
Esempio n. 48
0
def test_mutual_one_file_parent_valid_root_start_root(mutual_one_file):
    """
    Test two mutually recursive linked trees with one file, where the parent
    is valid, starting at the parent.
    """
    _, tmpdir = mutual_one_file
    tree = FSTree.at_path(tmpdir, {tmpdir})
    # Same result as before, but with the extra layer of 'a'; no top-level
    # 'd' folder because we already found it while recursing into 'a'.
    assert tree == FSTree({
        'a':
        FSTree({
            'b': FSTree({
                'c': FSTree({
                    'e': FSTree({
                        'g': None,
                    }),
                }),
            }),
        }),
    })
Esempio n. 49
0
def test_basic_ignore_tree_being_walked(basic):
    """Test ignoring the whole tree we're walking."""
    _, tmpdir = basic
    tree = FSTree.at_path(os.path.join(tmpdir, 'h'), {tmpdir}, ignore('h'))
    # Everything disappears
    assert tree == FSTree({})
Esempio n. 50
0
def test_mutual_empty(mutual_empty):
    """Test two mutually recursive linked trees with no files."""
    _, tmpdir = mutual_empty
    tree = FSTree.at_path(os.path.join(tmpdir, 'a'), {tmpdir})
    assert tree == FSTree({})
Esempio n. 51
0
def test_basic_ignore_tree_being_walked(basic):
    """Test ignoring the whole tree we're walking."""
    _, tmpdir = basic
    tree = FSTree.at_path(os.path.join(tmpdir, 'h'), {tmpdir}, ignore('h'))
    # Everything disappears
    assert tree == FSTree({})
Esempio n. 52
0
def test_basic_ignore_file_and_dir(basic):
    """Test ignoring some name used for file and directory."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('a'))
    # Everything disappears
    assert tree == FSTree({})
Esempio n. 53
0
def test_basic_ignore_file_and_dir(basic):
    """Test ignoring some name used for file and directory."""
    _, tmpdir = basic
    tree = FSTree.at_path(tmpdir, {tmpdir}, ignore('a'))
    # Everything disappears
    assert tree == FSTree({})
Esempio n. 54
0
def test_mutual_empty(mutual_empty):
    """Test two mutually recursive linked trees with no files."""
    _, tmpdir = mutual_empty
    tree = FSTree.at_path(os.path.join(tmpdir, 'a'), {tmpdir})
    assert tree == FSTree({})