def check_against_unittest(self, test_pattern, verbosity=0, **kwargs): """ Runs both unittest and nitpycker with the given test pattern and checks that both output matches :param test_pattern: pattern that test must match :param verbosity: verbosity with which the test :param kwargs: additional arguments to pass to the test runners """ with warnings.catch_warnings(): warnings.simplefilter("ignore", SerializationWarning) result1, unittest_output = run_tests(test_pattern, verbosity=verbosity, **kwargs) result2, nitpycker_output = run_tests(test_pattern, test_runner=ParallelRunner, verbosity=verbosity, **kwargs) regex_time_spent = r'Ran \d+ test(s)? in \d+\.\d+s' unittest_time = re.search(regex_time_spent, unittest_output) nitpycker_time = re.search(regex_time_spent, nitpycker_output) unittest_output = unittest_output[:unittest_time.start()] + unittest_output[unittest_time.end():] nitpycker_output = nitpycker_output[:nitpycker_time.start()] + nitpycker_output[nitpycker_time.end():] unittest_headers, unittest_output = self.extract_headers(unittest_output, verbosity) nitpycker_headers, nitpycker_output = self.extract_headers(nitpycker_output, verbosity) self.compare_outputs(set(unittest_output.split("\n\n")), set(nitpycker_output.split("\n\n"))) self.compare_headers(unittest_headers, nitpycker_headers, verbosity) self.assertEqual(result1, result2, "Didn't get the same return codes") self.assertEqual( unittest_time.group(0).split(" ")[1], nitpycker_time.group(0).split(" ")[1], msg="The number of tests ran by unittest and NitPycker is not the same" )
def test_against_unittest(self): test_pattern = "check_against_unittest.py" self.maxDiff = None unittest_output = run_tests(test_pattern) nitpycker_output = run_tests( test_pattern, test_runner=ParallelRunner, plugins_manager=Manager(), process_number=NUMBER_OF_PROCESS, verbosity=1 ) self.check_output(unittest_output, nitpycker_output)
def test_against_unittest(self): test_pattern = "check_against_unittest.py" self.maxDiff = None unittest_output = run_tests(test_pattern) nitpycker_output = run_tests(test_pattern, test_runner=ParallelRunner, plugins_manager=Manager(), process_number=NUMBER_OF_PROCESS, verbosity=1) self.check_output(unittest_output, nitpycker_output)
def test_isolation(self): nitpycker_output = run_tests( "check_isolation.py", test_runner=ParallelRunner, plugins_manager=Manager(), process_number=NUMBER_OF_PROCESS, verbosity=1 ) self.assertIn("OK", nitpycker_output, msg="An error occurred while running : \n{}".format(nitpycker_output))
def check_against_unittest(self, test_pattern, verbosity=0, **kwargs): """ Runs both unittest and nitpycker with the given test pattern and checks that both output matches :param test_pattern: pattern that test must match :param verbosity: verbosity with which the test :param kwargs: additional arguments to pass to the test runners """ with warnings.catch_warnings(): warnings.simplefilter("ignore", SerializationWarning) result1, unittest_output = run_tests(test_pattern, verbosity=verbosity, **kwargs) result2, nitpycker_output = run_tests(test_pattern, test_runner=ParallelRunner, verbosity=verbosity, **kwargs) regex_time_spent = r'Ran \d+ test(s)? in \d+\.\d+s' unittest_time = re.search(regex_time_spent, unittest_output) nitpycker_time = re.search(regex_time_spent, nitpycker_output) unittest_output = unittest_output[:unittest_time.start( )] + unittest_output[unittest_time.end():] nitpycker_output = nitpycker_output[:nitpycker_time.start( )] + nitpycker_output[nitpycker_time.end():] unittest_headers, unittest_output = self.extract_headers( unittest_output, verbosity) nitpycker_headers, nitpycker_output = self.extract_headers( nitpycker_output, verbosity) self.compare_outputs(set(unittest_output.split("\n\n")), set(nitpycker_output.split("\n\n"))) self.compare_headers(unittest_headers, nitpycker_headers, verbosity) self.assertEqual(result1, result2, "Didn't get the same return codes") self.assertEqual( unittest_time.group(0).split(" ")[1], nitpycker_time.group(0).split(" ")[1], msg= "The number of tests ran by unittest and NitPycker is not the same" )
def test_isolation(self): nitpycker_output = run_tests("check_isolation.py", test_runner=ParallelRunner, plugins_manager=Manager(), process_number=NUMBER_OF_PROCESS, verbosity=1) self.assertIn("OK", nitpycker_output, msg="An error occurred while running : \n{}".format( nitpycker_output))
def test_no_parallel_module(self): result, output = run_tests("check_module_no_parallel.py", test_runner=ParallelRunner, process_number=NUMBER_OF_PROCESS) self.check_error("OK", output, result)
def test_isolation(self): result, output = run_tests("check_isolation.py", test_runner=ParallelRunner, process_number=NUMBER_OF_PROCESS) self.check_error("OK", output, result)
def test_no_parallel_module(self): result, output = run_tests( "check_module_no_parallel.py", test_runner=ParallelRunner, process_number=NUMBER_OF_PROCESS) self.check_error("OK", output, result)
def test_isolation(self): result, output = run_tests( "check_isolation.py", test_runner=ParallelRunner, process_number=NUMBER_OF_PROCESS) self.check_error("OK", output, result)