Exemplo n.º 1
0
    def test_stat_lines_counts_zero_if_directory_does_not_exist(self):
        directory = mkdtemp("-caboose-non-exist-dir-test")
        inner = path.join(directory, 'nonexistant')

        fp = FilePackage()
        fp.add_directory(inner)
        file_iterator = FileIterator([fp])

        stat = StatLines()
        stat.set_files(file_iterator.files())
        eq_(0, stat.get_stat())
        rmtree(directory)
Exemplo n.º 2
0
    def test_proper_number_of_lines_are_counted_in_single_file(self):
        directory = mkdtemp("-caboose-numlines-single-test")
        self._create_file_with_n_lines(directory, 2)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        stat = StatLines()
        stat.set_files(file_iterator.files())
        eq_(2, stat.get_stat())
        rmtree(directory)
Exemplo n.º 3
0
    def test_proper_number_of_lines_are_counted_in_inner_dir(self):
        directory = mkdtemp("-caboose-numlines-inner-dir-test")
        inner = mkdtemp("-inner-dir", dir=directory)
        self._create_file_with_n_lines(directory, 2)
        self._create_file_with_n_lines(inner, 5)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        stat = StatLines()
        stat.set_files(file_iterator.files())
        eq_(7, stat.get_stat())
        rmtree(directory)
Exemplo n.º 4
0
    def test_proper_number_of_lines_in_multiple_dirs(self):
        directory = mkdtemp("-caboose-numlines-multiple-dir-test")
        inner1 = mkdtemp("-inner-dir1", dir=directory)
        inner2 = mkdtemp("-inner-dir2", dir=directory)
        inner3 = mkdtemp("-inner-dir3", dir=directory)
        self._create_file_with_n_lines(directory, 2)
        self._create_file_with_n_lines(inner1, 5)
        self._create_file_with_n_lines(inner2, 8)
        self._create_file_with_n_lines(inner3, 13)

        fp = FilePackage()
        fp.add_directories(inner1, inner3)
        file_iterator = FileIterator([fp])

        stat = StatLines()
        stat.set_files(file_iterator.files())
        eq_(18, stat.get_stat())
        rmtree(directory)
Exemplo n.º 5
0
    def test_use_preprocessor_when_requested(self):
        directory = mkdtemp("-caboose-numlines-single-test")
        self._create_file_with_n_lines(directory, 2)

        fp = FilePackage()
        fp.add_directory(directory)
        file_iterator = FileIterator([fp])

        ppf = MockPreProcessorFactory()
        stat = StatLines()
        stat.set_preprocessor_factory(ppf)
        stat.set_config({'preprocessor': 'name_here'})
        stat.set_files(file_iterator.files())
        stat.get_stat()
        ok_(ppf.get_preprocessor_called)
        eq_(ppf.preprocessor_name_requested, 'name_here')
        ok_(ppf.preprocessor.set_config_called)
        ok_(ppf.preprocessor.get_output_called)
        rmtree(directory)
Exemplo n.º 6
0
 def test_stat_has_right_name(self):
     eq_(StatLines.get_name(), "lines")