(args)
| 45 | |
| 46 | |
| 47 | def run_test(args): |
| 48 | test, allowed_failures_counter, buffer = args |
| 49 | # If we have exceeded the number of allowed failures during the test run, |
| 50 | # abort executing further tests immediately. |
| 51 | if allowed_failures_counter and allowed_failures_counter.value < 0: |
| 52 | return None |
| 53 | |
| 54 | # Handle setUpClass which needs to be called on each worker |
| 55 | # TODO: Better handling of exceptions that happen during setUpClass |
| 56 | if test.__class__ not in seen_class: |
| 57 | seen_class.add(test.__class__) |
| 58 | test.__class__.setUpClass() |
| 59 | |
| 60 | start_time = time.perf_counter() |
| 61 | olddir = os.getcwd() |
| 62 | result = BufferedParallelTestResult() |
| 63 | result.start_time = start_time |
| 64 | result.buffer = buffer |
| 65 | temp_dir = tempfile.mkdtemp(prefix='emtest_') |
| 66 | test.set_temp_dir(temp_dir) |
| 67 | try: |
| 68 | test(result) |
| 69 | except KeyboardInterrupt: |
| 70 | # In case of KeyboardInterrupt do not emit buffered stderr/stdout |
| 71 | # as we unwind. |
| 72 | result._mirrorOutput = False |
| 73 | finally: |
| 74 | result.elapsed = time.perf_counter() - start_time |
| 75 | |
| 76 | # Before attempting to delete the tmp dir make sure the current |
| 77 | # working directory is not within it. |
| 78 | os.chdir(olddir) |
| 79 | common.force_delete_dir(temp_dir) |
| 80 | |
| 81 | # Since we are returning this result to the main thread we need to make sure |
| 82 | # that it is serializable/picklable. To do this, we delete any non-picklable |
| 83 | # fields from the instance. |
| 84 | del result._original_stdout |
| 85 | del result._original_stderr |
| 86 | |
| 87 | return result |
| 88 | |
| 89 | |
| 90 | # Executes the teardown process once. Returns True if the teardown was |
nothing calls this directly
no test coverage detected