Skip to content

Commit

Permalink
A thread stress test
Browse files Browse the repository at this point in the history
(cherry picked from commit bc948ac1a5dca4d0a305a265de157d7505e4a4b2)
  • Loading branch information
nedbat committed Apr 9, 2019
1 parent 7c54226 commit cd15bc3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os.path
import re
import sqlite3
import threading

import mock

Expand Down Expand Up @@ -455,6 +456,21 @@ def test_read_and_write_are_opposites(self):
covdata2.read()
self.assert_arcs3_data(covdata2)

def test_thread_stress(self):
covdata = CoverageData()

def thread_main():
"""Every thread will try to add the same data."""
covdata.add_lines(LINES_1)

threads = [threading.Thread(target=thread_main) for _ in range(10)]
for t in threads:
t.start()
for t in threads:
t.join()

self.assert_lines1_data(covdata)


class CoverageDataTestInTempDir(DataTestHelpers, CoverageTest):
"""Tests of CoverageData that need a temporary directory to make files."""
Expand Down

0 comments on commit cd15bc3

Please sign in to comment.