Exemple #1
0
  def test_detect_hidden_paths(self):
    tmp_fld = mkdtemp()
    files = [touch(tmp_fld, ".test.py"), touch(tmp_fld, "test.py"), touch(tmp_fld, ".test2.py"),
             touch(tmp_fld, "test2.py")]

    paths = detect_paths([tmp_fld], hidden=False)
    without_dot = [files[1], files[3]]
    self.assertEqualItems(without_dot, paths)

    paths2 = detect_paths([tmp_fld], hidden=True)
    self.assertEqualItems(files, paths2)

    rmtree(tmp_fld)
Exemple #2
0
    def test_detect_vermin_paths_directly(self):
        tmp_fld = mkdtemp()

        # Won't be picked by heuristics.
        f = touch(tmp_fld, "no-shebang")
        with open(f, mode="w") as fp:
            fp.write("print('this is code')")

        paths = detect_paths([tmp_fld])
        self.assertEmpty(paths)

        paths = detect_paths([join(tmp_fld, "no-shebang")])
        self.assertEqual(paths, [f])

        rmtree(tmp_fld)
Exemple #3
0
 def test_detect_vermin_min_versions_parsable(self):
   paths = detect_paths([abspath("vermin")])
   processor = Processor()
   self.config.set_format(ParsableFormat())
   (mins, _incomp, _unique_versions, backports) = processor.process(paths, self.config)
   self.assertOnlyIn(((2, 7), (3, 0)), mins)
   self.assertEmpty(backports)
Exemple #4
0
 def test_detect_vermin_min_versions(self):
     paths = detect_paths([abspath("vermin")])
     processor = Processor()
     (mins, _incomp, _unique_versions, backports, used_novermin) =\
       processor.process(paths, self.config)
     self.assertOnlyIn(((2, 7), (3, 0)), mins)
     self.assertEmpty(backports)
     self.assertTrue(used_novermin)
Exemple #5
0
    def test_detect_hidden_paths(self):
        tmp_fld = mkdtemp()
        files = [
            touch(tmp_fld, ".test.py"),
            touch(tmp_fld, "test.py"),
            touch(tmp_fld, ".test2.py"),
            touch(tmp_fld, "test2.py")
        ]

        paths = detect_paths([tmp_fld], hidden=False)
        self.assertEqual([files[1], files[3]], paths)

        paths2 = detect_paths([tmp_fld], hidden=True)
        paths2.sort()
        files.sort()
        self.assertEqual(files, paths2)

        rmtree(tmp_fld)
Exemple #6
0
  def test_detect_vermin_paths_all_exts(self):
    tmp_fld = mkdtemp()

    exts = ('py', 'py3', 'pyw', 'pyj', 'pyi')
    for ext in exts:
      f = touch(tmp_fld, "code." + ext)
      with open(f, mode="w") as fp:
        fp.write("print('this is code')")

    found_exts = set()
    for path in detect_paths([tmp_fld]):
      _, ext = splitext(path)
      found_exts.add(ext[1:])
    self.assertEqualItems(found_exts, exts)

    rmtree(tmp_fld)
Exemple #7
0
  def test_detect_vermin_paths_no_invalid_exts(self):
    tmp_fld = mkdtemp()

    exts = ("pyc", "pyd", "pxd", "pyx", "pyo")
    for ext in exts:
      f = touch(tmp_fld, "code." + ext)
      with open(f, mode="w") as fp:
        fp.write("print('this is code')")

    # Since the detection ignores the extensions, no body of this for-loop will be executed.
    found_exts = set()
    for path in detect_paths([tmp_fld]):  # pragma: no cover
      _, ext = splitext(path)
      found_exts.add(ext[1:])
    self.assertEmpty(found_exts)

    rmtree(tmp_fld)
Exemple #8
0
 def test_detect_vermin_min_versions(self):
     paths = detect_paths([abspath("vermin")])
     (mins, incomp) = process_paths(paths, cpu_count())
     self.assertOnlyIn((2.7, 3.0), mins)
Exemple #9
0
 def test_detect_paths(self):
     paths = detect_paths([abspath("vermin")])
     self.assertEqual(13, len(paths))
Exemple #10
0
 def test_detect_vermin_min_versions(self):
     paths = detect_paths([abspath("vermin")])
     processor = Processor()
     (mins, incomp, unique_versions, backports) = processor.process(paths)
     self.assertOnlyIn(((2, 7), (3, 0)), mins)
     self.assertEmpty(backports)
Exemple #11
0
 def test_detect_vermin_min_versions(self):
     paths = detect_paths([abspath("vermin")])
     processor = Processor()
     (mins, incomp, unique_versions) = processor.process(paths)
     self.assertOnlyIn((2.7, 3.0), mins)