def test_explicitFiles():
    """
        If one of the paths given to iter_source_code is not a directory but
        a file, it will include that in its output
    """
    epath = make_empty_file('e.py')
    assert list(iter_source_code([epath])) == [epath]
Ejemplo n.º 2
0
def test_recurses():
    """If the Python files are hidden deep down in child directories, we will find them."""
    os.mkdir(os.path.join(TEMP_DIR, 'foo'))
    apath = make_empty_file('foo', 'a.py')
    os.mkdir(os.path.join(TEMP_DIR, 'bar'))
    bpath = make_empty_file('bar', 'b.py')
    cpath = make_empty_file('c.py')
    assert sorted(iter_source_code([TEMP_DIR])) == sorted([apath, bpath, cpath])
Ejemplo n.º 3
0
def test_recurses():
    """If the Python files are hidden deep down in child directories, we will find them."""
    os.mkdir(os.path.join(TEMP_DIR, 'foo'))
    apath = make_empty_file('foo', 'a.py')
    os.mkdir(os.path.join(TEMP_DIR, 'bar'))
    bpath = make_empty_file('bar', 'b.py')
    cpath = make_empty_file('c.py')
    assert sorted(iter_source_code([TEMP_DIR
                                    ])) == sorted([apath, bpath, cpath])
Ejemplo n.º 4
0
def test_multipleDirectories():
    """iter_source_code can be given multiple directories - it will recurse into each of them"""
    foopath = os.path.join(TEMP_DIR, 'foo')
    barpath = os.path.join(TEMP_DIR, 'bar')
    os.mkdir(foopath)
    apath = make_empty_file('foo', 'a.py')
    os.mkdir(barpath)
    bpath = make_empty_file('bar', 'b.py')
    assert sorted(iter_source_code([foopath, barpath])) == sorted([apath, bpath])
Ejemplo n.º 5
0
def test_multipleDirectories():
    """iter_source_code can be given multiple directories - it will recurse into each of them"""
    foopath = os.path.join(TEMP_DIR, 'foo')
    barpath = os.path.join(TEMP_DIR, 'bar')
    os.mkdir(foopath)
    apath = make_empty_file('foo', 'a.py')
    os.mkdir(barpath)
    bpath = make_empty_file('bar', 'b.py')
    assert sorted(iter_source_code([foopath,
                                    barpath])) == sorted([apath, bpath])
Ejemplo n.º 6
0
    def run(self):
        reporter = ProspectorReporter(ignore=self.ignore_codes)

        for filepath in iter_source_code(self._paths):
            if any([ip.search(filepath) for ip in self._ignores]):
                continue

            check_path(filepath, reporter)

        return reporter.get_messages()
Ejemplo n.º 7
0
    def run(self):
        reporter = ProspectorReporter(ignore=self.ignore_codes)

        for filepath in iter_source_code(self._paths):
            if any([ip.search(filepath) for ip in self._ignores]):
                continue

            check_path(filepath, reporter)

        return reporter.get_messages()
Ejemplo n.º 8
0
def test_explicitFiles():
    """If one of the paths given to iter_source_code is not a directory but a
    file, it will include that in its output."""
    epath = make_empty_file('e.py')
    assert list(iter_source_code([epath])) == [epath]
Ejemplo n.º 9
0
def test_onlyPythonSource():
    """Files that are not Python source files are not included."""
    make_empty_file('foo.pyc')
    assert list(iter_source_code([TEMP_DIR])) == []
Ejemplo n.º 10
0
def test_singleFile():
    """If the directory contains one Python file - iter_source_code will find it"""
    childpath = make_empty_file('foo.py')
    assert list(iter_source_code([TEMP_DIR])) == [childpath]
Ejemplo n.º 11
0
def test_emptyDirectory():
    """There are no Python files in an empty directory."""
    assert list(iter_source_code([TEMP_DIR])) == []
Ejemplo n.º 12
0
def test_onlyPythonSource():
    """Files that are not Python source files are not included."""
    make_empty_file('foo.pyc')
    assert list(iter_source_code([TEMP_DIR])) == []
Ejemplo n.º 13
0
def test_singleFile():
    """If the directory contains one Python file - iter_source_code will find it"""
    childpath = make_empty_file('foo.py')
    assert list(iter_source_code([TEMP_DIR])) == [childpath]
Ejemplo n.º 14
0
def test_emptyDirectory():
    """There are no Python files in an empty directory."""
    assert list(iter_source_code([TEMP_DIR])) == []