curds: Switch to using the asyncio module for testing threading

I'm planning to use the asyncio code for running background threads, so
let's switch to it for now to get a feel for how it works.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2019-02-05 16:20:31 -05:00
parent 2a98aac6de
commit 9b64c590cc
1 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,7 @@
# Copyright 2019 (c) Anna Schumaker
import asyncio
import concurrent.futures
import hashlib
from multiprocessing.pool import ThreadPool
import unittest
import album
@ -58,8 +59,8 @@ class TestAlbumClass(unittest.TestCase):
def test_parallel_lookup(self):
album.album_map.clear()
with ThreadPool(processes=5) as pool:
res = pool.map(album.lookup, [ album_info ] * 20)
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as pool:
res = list(pool.map(album.lookup, [ album_info ] * 20))
self.assertIsNotNone(res[0])
self.assertEqual(res.count(res[0]), 20)
self.assertEqual(len(album.album_map), 1)