Example #1
0
 def test_fetchdataStream(self):
     """
     run() can use a fetchdataStream for output.
     """
     gs = fetchdataStream(self.stream)
     run(fetchdataTestSuite(), gs, args=self.args)
     self.assertIn('No Tests Found', self.stream.getvalue())
Example #2
0
 def test_empty(self):
     """
     run() does not crash with empty suite and processes
     """
     suite = fetchdataTestSuite()
     self.args.processes = 2
     self.args.termcolor = False
     run(suite, self.stream, self.args)
Example #3
0
 def test_stdout(self):
     """
     run() can use sys.stdout as the stream.
     """
     saved_stdout = sys.stdout
     sys.stdout = self.stream
     self.addCleanup(setattr, sys, 'stdout', saved_stdout)
     run(fetchdataTestSuite(), sys.stdout, args=self.args)
     self.assertIn('No Tests Found', self.stream.getvalue())
Example #4
0
 def test_allow_stdout(self):
     """
     The allow_stdout setting should not get ignored.
     """
     class Object(object):
         pass
     args = Object()
     args.allow_stdout = True
     gts = fetchdataTestSuite(args=args)
     self.assertEqual(gts.allow_stdout, True)
Example #5
0
 def test_shouldStop(self):
     """
     When result.shouldStop == True, the suite should exit early.
     """
     mock_test = MagicMock()
     gts = fetchdataTestSuite(args=default_args)
     gts._tests = (mock_test,)
     mock_result = MagicMock()
     mock_result.shouldStop = True
     gts.run(mock_result)
Example #6
0
 def test_failedSetup(self):
     """
     When class setup fails, we skip to the next test.
     """
     mock_test = MagicMock()
     mock_test.__iter__.side_effect = TypeError
     gts = fetchdataTestSuite(args=default_args)
     gts._tests = (mock_test,)
     mock_result = MagicMock()
     mock_result._moduleSetUpFailed = True
     mock_result.shouldStop = False
     gts.run(mock_result)
Example #7
0
 def test_addTest_testPattern(self):
     """
     Setting test_pattern will cause a test to be filtered.
     """
     mock_test = MagicMock()
     mock_test._testMethodName = 'test_hello'
     mock_test2 = MagicMock()
     mock_test2._testMethodName = 'test_goodbye'
     args = copy.deepcopy(default_args)
     args.test_pattern = '_good*'
     gts = fetchdataTestSuite(args=args)
     gts.addTest(mock_test)
     self.assertEqual(gts._tests, [])
     gts.addTest(mock_test2)
     self.assertEqual(gts._tests, [mock_test2])
Example #8
0
 def test_defaultArgs(self):
     """
     Passing in default arguments causes attributes to be set.
     """
     gts = fetchdataTestSuite(args=default_args)
     self.assertEqual(gts.allow_stdout, default_args.allow_stdout)
Example #9
0
 def test_empty(self):
     """
     An empty suite can be instantiated.
     """
     fetchdataTestSuite()
Example #10
0
 def test_noTestsFound(self):
     """
     When we don't find any tests, we say so.
     """
     run(fetchdataTestSuite(), self.stream, self.args)
     self.assertIn('No Tests Found', self.stream.getvalue())