示例#1
0
 def test_error(self):
     """
     Exception raised running unit test is reported as an error
     """
     # Parent directory setup
     os.chdir(self.tmpdir)
     sub_tmpdir = tempfile.mkdtemp(dir=self.tmpdir)
     basename = os.path.basename(sub_tmpdir)
     # Child setup
     fh = open(os.path.join(basename, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     fh = open(os.path.join(basename, 'test_pool_runner_dotted_fail.py'), 'w')
     fh.write(dedent(
         """
         import unittest
         class A(unittest.TestCase):
             def testError(self):
                 raise AttributeError
         """))
     fh.close()
     module_name = basename + '.test_pool_runner_dotted_fail.A.testError'
     result = Queue()
     poolRunner(module_name, result)
     result.get()
     self.assertEqual(len(result.get().errors), 1)
示例#2
0
 def test_normalRun(self):
     """
     Runs normally
     """
     saved_coverage = process.coverage
     process.coverage = MagicMock()
     self.addCleanup(setattr, process, 'coverage', saved_coverage)
     # Parent directory setup
     os.chdir(self.tmpdir)
     sub_tmpdir = tempfile.mkdtemp(dir=self.tmpdir)
     basename = os.path.basename(sub_tmpdir)
     # Child setup
     fh = open(os.path.join(basename, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     fh = open(os.path.join(basename, 'test_pool_runner_dotted.py'), 'w')
     fh.write(dedent(
         """
         import unittest
         class A(unittest.TestCase):
             def testPass(self):
                 pass
         """))
     fh.close()
     module_name = basename + '.test_pool_runner_dotted.A.testPass'
     result = Queue()
     poolRunner(module_name, result, 1)
     result.get()
     self.assertEqual(len(result.get().passing), 1)
示例#3
0
 def test_SyntaxErrorInUnitTest(self):
     """
     SyntaxError gets reported as an error loading the unit test
     """
     saved_coverage = process.coverage
     process.coverage = MagicMock()
     self.addCleanup(setattr, process, 'coverage', saved_coverage)
     # Parent directory setup
     os.chdir(self.tmpdir)
     sub_tmpdir = tempfile.mkdtemp(dir=self.tmpdir)
     basename = os.path.basename(sub_tmpdir)
     # Child setup
     fh = open(os.path.join(basename, '__init__.py'), 'w')
     fh.write('\n')
     fh.close()
     fh = open(os.path.join(basename, 'test_pool_syntax_error.py'), 'w')
     fh.write("aoeu")
     fh.close()
     result = Queue()
     poolRunner(basename, result, 1)
     result.get()
     self.assertEqual(len(result.get().errors), 1)