示例#1
0
    def test_regexs(self):
        uut = BearCollector(["kind"],
                            flat_bear_dirs=[self.parent_from_tmp],
                            regex="testfile1.*")
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 0)

        uut = BearCollector(["kind"],
                            rec_bear_dirs=[self.parent_from_tmp],
                            regex="testfile1")
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 0)

        uut = BearCollector(["kind"],
                            rec_bear_dirs=[self.parent_from_tmp],
                            regex="testfile1.*")
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 1)
        self.assertEqual(bear_list[0]().origin(), self.testfile1_path)

        uut = BearCollector(["kind"],
                            rec_bear_dirs=[self.parent_from_tmp],
                            regex="^testfile1.*$")
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 1)
        self.assertEqual(bear_list[0]().origin(), self.testfile1_path)

        uut = BearCollector(["kind"],
                            rec_bear_dirs=[self.parent_from_tmp],
                            regex="*^testfile1.*$")
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 0)
示例#2
0
    def test_bear_names(self):
        uut = BearCollector(["kind"],
                            flat_bear_dirs=[self.tmp_dir],
                            bear_names=[
                                os.path.splitext(
                                    os.path.basename(self.testfile1_path))[0]
                            ])
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 1)
        self.assertEqual(bear_list[0]().origin(), self.testfile1_path)

        uut = BearCollector(["kind"], flat_bear_dirs=[self.tmp_dir])
        bear_list = uut.collect()
        self.assertEqual(len(bear_list), 0)
示例#3
0
 def test_ignored(self):
     uut = BearCollector(["kind"],
                         flat_bear_dirs=[self.tmp_dir],
                         ignored_bears=[
                             os.path.splitext(
                                 os.path.basename(self.testfile1_path))[0]
                         ],
                         regex=".*")
     bear_list = uut.collect()
     self.assertEqual(len(bear_list), 1)
     self.assertEqual(bear_list[0]().origin(), self.testfile2_path)
示例#4
0
 def test_bear_import(self):
     uut = BearCollector(["kind"],
                         flat_bear_dirs=[self.tmp_dir],
                         regex=".*")
     bear_list = uut.collect()
     self.assertEqual(len(bear_list), 2)
     self.assertTrue([bear_class().origin()
                      for bear_class in bear_list] in [
                          list(Tuple) for Tuple in itertools.permutations(
                              [self.testfile1_path, self.testfile2_path])
                      ])