Exemple #1
0
 def test_symlink(self):
     """
     If the directory is a symlink, it should be skipped.
     """
     if platform.system() == 'Windows':  # pragma: no cover
         self.skipTest('This test is for posix-specific behavior')
     tmpdir = tempfile.mkdtemp()
     tmpdir2 = tempfile.mkdtemp()
     os.symlink(tmpdir, os.path.join(tmpdir2, 'link'))
     self.addCleanup(shutil.rmtree, tmpdir)
     startdir = os.getcwd()
     os.chdir(tmpdir)
     self.addCleanup(os.chdir, startdir)
     pkg_name = 'realpkg'
     os.mkdir(pkg_name)
     tmp_subdir = os.path.join(tmpdir, pkg_name)
     fh = open(os.path.join(tmp_subdir, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     named_module = os.path.join(os.path.basename(tmp_subdir),
                                 'test_module.py')
     fh = open(named_module, 'w')
     fh.write(
         dedent("""
         import unittest
         class A(unittest.TestCase):
             def testPass(self):
                 pass
         """))
     fh.close()
     self.assertEqual(loader.discover(tmpdir2), None)
Exemple #2
0
 def test_symlink(self):
     """
     If the directory is a symlink, it should be skipped.
     """
     if platform.system() == 'Windows':  # pragma: no cover
         self.skipTest('This test is for posix-specific behavior')
     tmpdir  = tempfile.mkdtemp()
     tmpdir2 = tempfile.mkdtemp()
     os.symlink(tmpdir, os.path.join(tmpdir2, 'link'))
     self.addCleanup(shutil.rmtree, tmpdir)
     startdir = os.getcwd()
     os.chdir(tmpdir)
     self.addCleanup(os.chdir, startdir)
     pkg_name = 'realpkg'
     os.mkdir(pkg_name)
     tmp_subdir = os.path.join(tmpdir, pkg_name)
     fh = open(os.path.join(tmp_subdir, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     named_module = os.path.join(os.path.basename(tmp_subdir),
                                 'test_module.py')
     fh = open(named_module, 'w')
     fh.write(dedent(
         """
         import unittest
         class A(unittest.TestCase):
             def testPass(self):
                 pass
         """))
     fh.close()
     self.assertEqual(loader.discover(tmpdir2), None)
Exemple #3
0
 def test_bad_pkg_name(self):
     """
     If the directory is an invalid package name, don't bother looking in
     it.
     """
     tmpdir = tempfile.mkdtemp()
     self.addCleanup(shutil.rmtree, tmpdir)
     startdir = os.getcwd()
     os.chdir(tmpdir)
     self.addCleanup(os.chdir, startdir)
     bad_pkg_name = '1badname'
     os.mkdir(bad_pkg_name)
     tmp_subdir = os.path.join(tmpdir, bad_pkg_name)
     fh = open(os.path.join(tmp_subdir, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     named_module = os.path.join(os.path.basename(tmp_subdir),
                                 'named_module.py')
     fh = open(named_module, 'w')
     fh.write(
         dedent("""
         import unittest
         class A(unittest.TestCase):
             def testPass(self):
                 pass
         """))
     fh.close()
     self.assertEqual(loader.discover(tmpdir), None)
Exemple #4
0
 def test_bad_pkg_name(self):
     """
     If the directory is an invalid package name, don't bother looking in
     it.
     """
     tmpdir = tempfile.mkdtemp()
     self.addCleanup(shutil.rmtree, tmpdir)
     startdir = os.getcwd()
     os.chdir(tmpdir)
     self.addCleanup(os.chdir, startdir)
     bad_pkg_name = '1badname'
     os.mkdir(bad_pkg_name)
     tmp_subdir = os.path.join(tmpdir, bad_pkg_name)
     fh = open(os.path.join(tmp_subdir, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     named_module = os.path.join(os.path.basename(tmp_subdir),
                                 'named_module.py')
     fh = open(named_module, 'w')
     fh.write(dedent(
         """
         import unittest
         class A(unittest.TestCase):
             def testPass(self):
                 pass
         """))
     fh.close()
     self.assertEqual(loader.discover(tmpdir), None)