forked from slackapi/python-slack-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_issue_480.py
64 lines (55 loc) · 2.14 KB
/
test_issue_480.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import logging
import multiprocessing
import os
import threading
import unittest
from integration_tests.env_variable_names import SLACK_SDK_TEST_USER_TOKEN
from integration_tests.helpers import async_test
from slack import WebClient
class TestWebClient(unittest.TestCase):
"""Runs integration tests with real Slack API
https://github.com/slackapi/python-slackclient/issues/480
"""
def setUp(self):
self.logger = logging.getLogger(__name__)
self.user_token = os.environ[SLACK_SDK_TEST_USER_TOKEN]
self.sync_client: WebClient = WebClient(token=self.user_token, run_async=False)
self.async_client: WebClient = WebClient(token=self.user_token, run_async=True)
def tearDown(self):
pass
def test_issue_480_processes(self):
client = self.sync_client
before = len(multiprocessing.active_children())
for idx in range(10):
response = client.api_test()
self.assertIsNotNone(response)
after = len(multiprocessing.active_children())
self.assertEqual(0, after - before)
@async_test
async def test_issue_480_processes_async(self):
client = self.async_client
before = len(multiprocessing.active_children())
for idx in range(10):
response = await client.api_test()
self.assertIsNotNone(response)
after = len(multiprocessing.active_children())
self.assertEqual(0, after - before)
# fails with Python 3.6
def test_issue_480_threads(self):
client = self.sync_client
before = threading.active_count()
for idx in range(10):
response = client.api_test()
self.assertIsNotNone(response)
after = threading.active_count()
self.assertEqual(0, after - before)
# fails with Python 3.6
@async_test
async def test_issue_480_threads_async(self):
client = self.async_client
before = threading.active_count()
for idx in range(10):
response = await client.api_test()
self.assertIsNotNone(response)
after = threading.active_count()
self.assertEqual(0, after - before)