Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration tests and improve the the stability of existing unit tests #653

Merged
merged 23 commits into from Apr 22, 2020

Conversation

seratch
Copy link
Member

@seratch seratch commented Apr 20, 2020

Summary

This pull request improves the test settings and adds integration tests with real Slack APIs. This is a preparation for my forthcoming pull requests addressing the concurrency issues in this library.

  • Improve the usage of event loops in unit tests not to be affected by other tests
  • Add pytest.ini for detailed logging
  • Add python setup.py run_all_tests --test-target web
  • Move samples from tests to integration_tests as they require real tokens

Integration tests

The integration tests under the integration_tests directory are supposed to be executed manually by the maintainers. They won't be integrated into the CI builds at least in the short-term.

Env variables for integration_tests

The integration tests require real tokens and channel IDs to access in the tests.

# Bot token for WebClient tests
export SLACK_SDK_TEST_BOT_TOKEN=xoxb-***
export SLACK_SDK_TEST_USER_TOKEN=xoxp-***
export  SLACK_SDK_TEST_WEB_TEST_CHANNEL_ID=C1234567890

# Bot token for RTMClient tests
export SLACK_SDK_TEST_CLASSIC_APP_BOT_TOKEN=xoxb-***
export SLACK_SDK_TEST_RTM_TEST_CHANNEL_ID=C1234567890

New setuptools command - run_all_tests

A new setuptools command named run_all_tests is a handy way to run all the unit tests and integration tests. You can filter the tests to run by the --test-target option.

`python setup.py run_all_tests` outputs
$ python setup.py run_all_tests
running run_all_tests
Installing test dependencies…
/path-to-python/bin/python -m pip install pytest pytest-cov codecov flake8 black psutil
Requirement already satisfied: pytest in /path-to-python/lib/python3.8/site-packages (5.4.1)
Requirement already satisfied: pytest-cov in /path-to-python/lib/python3.8/site-packages (2.8.1)
Requirement already satisfied: codecov in /path-to-python/lib/python3.8/site-packages (2.0.22)
Requirement already satisfied: flake8 in /path-to-python/lib/python3.8/site-packages (3.7.9)
Requirement already satisfied: black in /path-to-python/lib/python3.8/site-packages (19.10b0)
Requirement already satisfied: psutil in /path-to-python/lib/python3.8/site-packages (5.7.0)
Requirement already satisfied: more-itertools>=4.0.0 in /path-to-python/lib/python3.8/site-packages (from pytest) (8.2.0)
Requirement already satisfied: pluggy<1.0,>=0.12 in /path-to-python/lib/python3.8/site-packages (from pytest) (0.13.1)
Requirement already satisfied: attrs>=17.4.0 in /path-to-python/lib/python3.8/site-packages (from pytest) (19.3.0)
Requirement already satisfied: wcwidth in /path-to-python/lib/python3.8/site-packages (from pytest) (0.1.9)
Requirement already satisfied: py>=1.5.0 in /path-to-python/lib/python3.8/site-packages (from pytest) (1.8.1)
Requirement already satisfied: packaging in /path-to-python/lib/python3.8/site-packages (from pytest) (20.3)
Requirement already satisfied: coverage>=4.4 in /path-to-python/lib/python3.8/site-packages (from pytest-cov) (5.0.4)
Requirement already satisfied: requests>=2.7.9 in /path-to-python/lib/python3.8/site-packages (from codecov) (2.22.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /path-to-python/lib/python3.8/site-packages (from flake8) (0.6.1)
Requirement already satisfied: entrypoints<0.4.0,>=0.3.0 in /path-to-python/lib/python3.8/site-packages (from flake8) (0.3)
Requirement already satisfied: pyflakes<2.2.0,>=2.1.0 in /path-to-python/lib/python3.8/site-packages (from flake8) (2.1.1)
Requirement already satisfied: pycodestyle<2.6.0,>=2.5.0 in /path-to-python/lib/python3.8/site-packages (from flake8) (2.5.0)
Requirement already satisfied: appdirs in /path-to-python/lib/python3.8/site-packages (from black) (1.4.3)
Requirement already satisfied: toml>=0.9.4 in /path-to-python/lib/python3.8/site-packages (from black) (0.10.0)
Requirement already satisfied: typed-ast>=1.4.0 in /path-to-python/lib/python3.8/site-packages (from black) (1.4.0)
Requirement already satisfied: pathspec<1,>=0.6 in /path-to-python/lib/python3.8/site-packages (from black) (0.8.0)
Requirement already satisfied: regex in /path-to-python/lib/python3.8/site-packages (from black) (2020.4.4)
Requirement already satisfied: click>=6.5 in /path-to-python/lib/python3.8/site-packages (from black) (7.1.1)
Requirement already satisfied: six in /path-to-python/lib/python3.8/site-packages (from packaging->pytest) (1.12.0)
Requirement already satisfied: pyparsing>=2.0.2 in /path-to-python/lib/python3.8/site-packages (from packaging->pytest) (2.4.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /path-to-python/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /path-to-python/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (2019.9.11)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /path-to-python/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (1.25.6)
Requirement already satisfied: idna<2.9,>=2.5 in /path-to-python/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (2.8)
Running black…
/path-to-python/bin/python -m black /Users/ksera/github/python-slackclient/slack
All done! ✨ 🍰 ✨
19 files left unchanged.
Running flake8…
/path-to-python/bin/python -m flake8 /Users/ksera/github/python-slackclient/slack
Running pytest…
/path-to-python/bin/python -m pytest --cov-report=xml --cov=/Users/ksera/github/python-slackclient/slack tests/
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ksera/github/python-slackclient, inifile: pytest.ini
plugins: cov-2.8.1
collected 134 items                                                                                                                                                                                                   

tests/test_asyncio_event_loops.py ...                                                                                                                                                                           [  2%]
tests/rtm/test_rtm_client.py ........                                                                                                                                                                           [  8%]
tests/rtm/test_rtm_client_functional.py ............                                                                                                                                                            [ 17%]
tests/web/test_web_client.py ...........                                                                                                                                                                        [ 25%]
tests/web/test_web_client_coverage.py .                                                                                                                                                                         [ 26%]
tests/web/test_web_client_functional.py ..                                                                                                                                                                      [ 27%]
tests/web/classes/test_actions.py ........                                                                                                                                                                      [ 33%]
tests/web/classes/test_attachments.py ..........                                                                                                                                                                [ 41%]
tests/web/classes/test_blocks.py ............                                                                                                                                                                   [ 50%]
tests/web/classes/test_dialogs.py ............                                                                                                                                                                  [ 58%]
tests/web/classes/test_elements.py ...............                                                                                                                                                              [ 70%]
tests/web/classes/test_objects.py ........................................                                                                                                                                      [100%]

================================================================================================== warnings summary ===================================================================================================
(omitted)

---------- coverage: platform darwin, python 3.8.2-final-0 -----------
Coverage XML written to file coverage.xml

========================================================================================== 134 passed, 429 warnings in 2.06s ==========================================================================================
Running pytest…
/path-to-python/bin/python -m pytest --cov-report=xml --cov=/Users/ksera/github/python-slackclient/slack integration_tests/
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ksera/github/python-slackclient, inifile: pytest.ini
plugins: cov-2.8.1
collected 14 items                                                                                                                                                                                                    

integration_tests/rtm/test_rtm_client.py ..s.                                                                                                                                                                   [ 28%]
integration_tests/web/test_web_client.py .........s                                                                                                                                                             [100%]

================================================================================================== warnings summary ===================================================================================================
(omitted)

---------- coverage: platform darwin, python 3.8.2-final-0 -----------
Coverage XML written to file coverage.xml

===================================================================================== 12 passed, 2 skipped, 79 warnings in 45.50s =====================================================================================
$ 

Requirements (place an x in each [ ])

@@ -111,7 +145,7 @@ def run(self):
include_package_data=True,
license="MIT",
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Development Status :: 5 - Production/Stable",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been incorrect since version 2.0.0 release. Allow me to include this fix.

@@ -124,12 +158,16 @@ def run(self):
],
keywords="slack slack-web slack-rtm chat chatbots bots chatops",
packages=find_packages(
exclude=["docs", "docs-src", "tests", "tests.*", "tutorial"]
exclude=["docs", "docs-src", "integration_tests", "tests", "tests.*", "tutorial"]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new director won't be included in the package.

`python3 setup.py sdist bdist_wheel --universal` outputs
$ python3 setup.py sdist bdist_wheel --universal
running sdist
running egg_info
writing slackclient.egg-info/PKG-INFO
writing dependency_links to slackclient.egg-info/dependency_links.txt
writing requirements to slackclient.egg-info/requires.txt
writing top-level names to slackclient.egg-info/top_level.txt
reading manifest file 'slackclient.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'slackclient.egg-info/SOURCES.txt'
running check
creating slackclient-2.6.0
creating slackclient-2.6.0/slack
creating slackclient-2.6.0/slack/rtm
creating slackclient-2.6.0/slack/web
creating slackclient-2.6.0/slack/web/classes
creating slackclient-2.6.0/slackclient.egg-info
copying files to slackclient-2.6.0...
copying LICENSE -> slackclient-2.6.0
copying MANIFEST.in -> slackclient-2.6.0
copying README.md -> slackclient-2.6.0
copying setup.cfg -> slackclient-2.6.0
copying setup.py -> slackclient-2.6.0
copying slack/__init__.py -> slackclient-2.6.0/slack
copying slack/errors.py -> slackclient-2.6.0/slack
copying slack/py.typed -> slackclient-2.6.0/slack
copying slack/version.py -> slackclient-2.6.0/slack
copying slack/rtm/__init__.py -> slackclient-2.6.0/slack/rtm
copying slack/rtm/client.py -> slackclient-2.6.0/slack/rtm
copying slack/web/__init__.py -> slackclient-2.6.0/slack/web
copying slack/web/base_client.py -> slackclient-2.6.0/slack/web
copying slack/web/client.py -> slackclient-2.6.0/slack/web
copying slack/web/slack_response.py -> slackclient-2.6.0/slack/web
copying slack/web/classes/__init__.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/actions.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/attachments.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/blocks.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/dialog_elements.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/dialogs.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/elements.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/interactions.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/messages.py -> slackclient-2.6.0/slack/web/classes
copying slack/web/classes/objects.py -> slackclient-2.6.0/slack/web/classes
copying slackclient.egg-info/PKG-INFO -> slackclient-2.6.0/slackclient.egg-info
copying slackclient.egg-info/SOURCES.txt -> slackclient-2.6.0/slackclient.egg-info
copying slackclient.egg-info/dependency_links.txt -> slackclient-2.6.0/slackclient.egg-info
copying slackclient.egg-info/requires.txt -> slackclient-2.6.0/slackclient.egg-info
copying slackclient.egg-info/top_level.txt -> slackclient-2.6.0/slackclient.egg-info
Writing slackclient-2.6.0/setup.cfg
Creating tar archive
removing 'slackclient-2.6.0' (and everything under it)
running bdist_wheel
running build
running build_py
installing to build/bdist.macosx-10.15-x86_64/wheel
running install
running install_lib
creating build/bdist.macosx-10.15-x86_64/wheel
creating build/bdist.macosx-10.15-x86_64/wheel/slack
copying build/lib/slack/version.py -> build/bdist.macosx-10.15-x86_64/wheel/slack
creating build/bdist.macosx-10.15-x86_64/wheel/slack/web
copying build/lib/slack/web/slack_response.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web
creating build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/elements.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/actions.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/__init__.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/dialog_elements.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/attachments.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/messages.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/interactions.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/dialogs.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/blocks.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/classes/objects.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web/classes
copying build/lib/slack/web/base_client.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web
copying build/lib/slack/web/client.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web
copying build/lib/slack/web/__init__.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/web
copying build/lib/slack/__init__.py -> build/bdist.macosx-10.15-x86_64/wheel/slack
creating build/bdist.macosx-10.15-x86_64/wheel/slack/rtm
copying build/lib/slack/rtm/client.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/rtm
copying build/lib/slack/rtm/__init__.py -> build/bdist.macosx-10.15-x86_64/wheel/slack/rtm
copying build/lib/slack/py.typed -> build/bdist.macosx-10.15-x86_64/wheel/slack
copying build/lib/slack/errors.py -> build/bdist.macosx-10.15-x86_64/wheel/slack
running install_egg_info
Copying slackclient.egg-info to build/bdist.macosx-10.15-x86_64/wheel/slackclient-2.6.0-py3.8.egg-info
running install_scripts
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.macosx-10.15-x86_64/wheel/slackclient-2.6.0.dist-info/WHEEL
creating 'dist/slackclient-2.6.0-py2.py3-none-any.whl' and adding 'build/bdist.macosx-10.15-x86_64/wheel' to it
adding 'slack/__init__.py'
adding 'slack/errors.py'
adding 'slack/py.typed'
adding 'slack/version.py'
adding 'slack/rtm/__init__.py'
adding 'slack/rtm/client.py'
adding 'slack/web/__init__.py'
adding 'slack/web/base_client.py'
adding 'slack/web/client.py'
adding 'slack/web/slack_response.py'
adding 'slack/web/classes/__init__.py'
adding 'slack/web/classes/actions.py'
adding 'slack/web/classes/attachments.py'
adding 'slack/web/classes/blocks.py'
adding 'slack/web/classes/dialog_elements.py'
adding 'slack/web/classes/dialogs.py'
adding 'slack/web/classes/elements.py'
adding 'slack/web/classes/interactions.py'
adding 'slack/web/classes/messages.py'
adding 'slack/web/classes/objects.py'
adding 'slackclient-2.6.0.dist-info/LICENSE'
adding 'slackclient-2.6.0.dist-info/METADATA'
adding 'slackclient-2.6.0.dist-info/WHEEL'
adding 'slackclient-2.6.0.dist-info/top_level.txt'
adding 'slackclient-2.6.0.dist-info/RECORD'
removing build/bdist.macosx-10.15-x86_64/wheel

@@ -12,7 +12,7 @@

class TestRTMClient(unittest.TestCase):
def setUp(self):
self.client = slack.RTMClient(token="xoxp-1234", auto_reconnect=False)
self.client = slack.RTMClient(token="xoxp-1234", auto_reconnect=False, loop=asyncio.get_event_loop())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, this will be necessary when we add more tests.

num = 1000
clients = []
for i in range(num):
clients.append(WebClient(token="xoxb-test", run_async=False))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WebClient currently never generates a large number of event loops internally.

While working on a possible solution to address concurrency issues with run_sync=False clients, I was assessing the possibility to have asyncio.new_event_loop() and hold an independent loop inside. I found it may work in small scripts but it causes the file descriptor issue as shown in the above case (test_the_cost_of_event_loop_creation) if the app creates 100+ instances.

So, these tests are preventive measures of making such wrong decisions, just in case.

@@ -39,6 +39,8 @@ def setUp(self):

def tearDown(self):
self.loop.run_until_complete(self.site.stop())
if not self.loop.is_closed():
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just minor improvement

@@ -74,7 +74,7 @@ def stop_on_open(**payload):
self.assertEqual(rtm_client._connection_attempts, 2)
rtm_client.stop()

client = slack.RTMClient(token="xoxa-1234", auto_reconnect=True)
client = slack.RTMClient(token="xoxa-1234", auto_reconnect=True, loop=self.loop)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

if current_cpu_usage > TestRTMClient.cpu_usage:
TestRTMClient.cpu_usage = current_cpu_usage

TestRTMClient.cpu_monitor = threading.Thread(target=run_cpu_monitor, args=[self])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the CPU usage of running this thread in the same process is ignorable, it may be also fine to have another process instead.

self.assertEqual(self.sent_text, text)

# TODO: Fix this issue
@pytest.mark.skip("This needs to be fixed - https://github.com/slackapi/python-slackclient/issues/569")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove this mark in the PR addressing #569

# TODO: Fix this issue
@pytest.mark.skip
@async_test
async def test_pagination_with_iterator_async(self):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No one has reported this issue but run_async=True mode doesn't allow pagination using next_cursor iterators. I'm not sure about the best way to resolve this but at least, we need to change the internals not to call run_until_complete.

@seratch seratch added this to the 2.6.0 milestone Apr 20, 2020
@seratch
Copy link
Member Author

seratch commented Apr 20, 2020

@seratch
Copy link
Member Author

seratch commented Apr 20, 2020

TODO:

@codecov
Copy link

codecov bot commented Apr 20, 2020

Codecov Report

Merging #653 into master will increase coverage by 0.47%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #653      +/-   ##
==========================================
+ Coverage   86.67%   87.14%   +0.47%     
==========================================
  Files          15       15              
  Lines        1749     1821      +72     
  Branches       99       99              
==========================================
+ Hits         1516     1587      +71     
- Misses        201      202       +1     
  Partials       32       32              
Impacted Files Coverage Δ
slack/web/slack_response.py 100.00% <0.00%> (ø)
slack/web/classes/messages.py 0.00% <0.00%> (ø)
slack/web/classes/actions.py 98.94% <0.00%> (+0.07%) ⬆️
slack/rtm/client.py 83.33% <0.00%> (+0.09%) ⬆️
slack/web/classes/attachments.py 98.92% <0.00%> (+0.11%) ⬆️
slack/web/base_client.py 79.81% <0.00%> (+0.18%) ⬆️
slack/web/classes/objects.py 95.39% <0.00%> (+0.25%) ⬆️
slack/web/classes/blocks.py 94.73% <0.00%> (+0.48%) ⬆️
slack/web/classes/dialog_elements.py 94.44% <0.00%> (+0.79%) ⬆️
slack/web/classes/elements.py 86.31% <0.00%> (+0.92%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0911726...feaa701. Read the comment docs.

@seratch
Copy link
Member Author

seratch commented Apr 20, 2020

TODO:

  • Add files.upload tests to integration_tests/test_web_client.py
  • Add oauth.v2.access sample to integration_tests/samples/others/oauth_callback.py (new one)

@seratch
Copy link
Member Author

seratch commented Apr 21, 2020

Tests for unfixed issues are still marked as @pytest.mark.skipbut now we can run the tests by python setup.py run_all_tests.

$ python setup.py run_all_tests ...
$ python setup.py run_all_tests
running run_all_tests
Installing test dependencies…
/Users/ksera/.pyenv/versions/3.8.2/bin/python -m pip install pytest pytest-cov codecov flake8 black psutil
Requirement already satisfied: pytest in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (5.4.1)
Requirement already satisfied: pytest-cov in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (2.8.1)
Requirement already satisfied: codecov in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (2.0.22)
Requirement already satisfied: flake8 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (3.7.9)
Requirement already satisfied: black in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (19.10b0)
Requirement already satisfied: psutil in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (5.7.0)
Requirement already satisfied: wcwidth in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (0.1.9)
Requirement already satisfied: py>=1.5.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (1.8.1)
Requirement already satisfied: packaging in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (20.3)
Requirement already satisfied: attrs>=17.4.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (19.3.0)
Requirement already satisfied: more-itertools>=4.0.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (8.2.0)
Requirement already satisfied: pluggy<1.0,>=0.12 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest) (0.13.1)
Requirement already satisfied: coverage>=4.4 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from pytest-cov) (5.0.4)
Requirement already satisfied: requests>=2.7.9 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from codecov) (2.22.0)
Requirement already satisfied: entrypoints<0.4.0,>=0.3.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from flake8) (0.3)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from flake8) (0.6.1)
Requirement already satisfied: pyflakes<2.2.0,>=2.1.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from flake8) (2.1.1)
Requirement already satisfied: pycodestyle<2.6.0,>=2.5.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from flake8) (2.5.0)
Requirement already satisfied: appdirs in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (1.4.3)
Requirement already satisfied: pathspec<1,>=0.6 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (0.8.0)
Requirement already satisfied: regex in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (2020.4.4)
Requirement already satisfied: typed-ast>=1.4.0 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (1.4.0)
Requirement already satisfied: click>=6.5 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (7.1.1)
Requirement already satisfied: toml>=0.9.4 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from black) (0.10.0)
Requirement already satisfied: pyparsing>=2.0.2 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from packaging->pytest) (2.4.7)
Requirement already satisfied: six in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from packaging->pytest) (1.12.0)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (1.25.6)
Requirement already satisfied: idna<2.9,>=2.5 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (2.8)
Requirement already satisfied: certifi>=2017.4.17 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (2019.9.11)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages (from requests>=2.7.9->codecov) (3.0.4)
Running black…
/Users/ksera/.pyenv/versions/3.8.2/bin/python -m black /Users/ksera/github/python-slackclient/slack
All done! ✨ 🍰 ✨
19 files left unchanged.
Running flake8…
/Users/ksera/.pyenv/versions/3.8.2/bin/python -m flake8 /Users/ksera/github/python-slackclient/slack
Running pytest…
/Users/ksera/.pyenv/versions/3.8.2/bin/python -m pytest --cov-report=xml --cov=/Users/ksera/github/python-slackclient/slack tests/
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ksera/github/python-slackclient, inifile: pytest.ini
plugins: cov-2.8.1
collected 134 items                                                                                                                                                                                                   

tests/test_asyncio_event_loops.py .s.                                                                                                                                                                           [  2%]
tests/rtm/test_rtm_client.py ........                                                                                                                                                                           [  8%]
tests/rtm/test_rtm_client_functional.py ............                                                                                                                                                            [ 17%]
tests/web/test_web_client.py ...........                                                                                                                                                                        [ 25%]
tests/web/test_web_client_coverage.py .                                                                                                                                                                         [ 26%]
tests/web/test_web_client_functional.py ..                                                                                                                                                                      [ 27%]
tests/web/classes/test_actions.py ........                                                                                                                                                                      [ 33%]
tests/web/classes/test_attachments.py ..........                                                                                                                                                                [ 41%]
tests/web/classes/test_blocks.py ............                                                                                                                                                                   [ 50%]
tests/web/classes/test_dialogs.py ............                                                                                                                                                                  [ 58%]
tests/web/classes/test_elements.py ...............                                                                                                                                                              [ 70%]
tests/web/classes/test_objects.py ........................................                                                                                                                                      [100%]

================================================================================================== warnings summary ===================================================================================================
/Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/helpers.py:107
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/helpers.py:107: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def noop(*args, **kwargs):  # type: ignore

tests/rtm/test_rtm_client.py: 1 test with warning
tests/rtm/test_rtm_client_functional.py: 12 tests with warnings
  /Users/ksera/github/python-slackclient/tests/helpers.py:59: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    corofunc = Mock(name="mock_rtm_response", side_effect=asyncio.coroutine(coro))

tests/rtm/test_rtm_client_functional.py: 14 tests with warnings
tests/web/test_web_client_coverage.py: 179 tests with warnings
tests/web/test_web_client_functional.py: 3 tests with warnings
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
    hosts = await asyncio.shield(self._resolve_host(

tests/rtm/test_rtm_client_functional.py: 14 tests with warnings
tests/web/test_web_client_coverage.py: 179 tests with warnings
tests/web/test_web_client_functional.py: 3 tests with warnings
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/locks.py:21: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
    self._event = asyncio.Event(loop=loop)

tests/rtm/test_rtm_client_functional.py: 12 tests with warnings
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/web_server.py:53: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
    await asyncio.gather(*coros, loop=self._loop)

tests/web/test_web_client.py: 11 tests with warnings
  /Users/ksera/github/python-slackclient/tests/helpers.py:79: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    send_request = Mock(name="Request", side_effect=asyncio.coroutine(response_mock))

-- Docs: https://docs.pytest.org/en/latest/warnings.html

---------- coverage: platform darwin, python 3.8.2-final-0 -----------
Coverage XML written to file coverage.xml

==================================================================================== 133 passed, 1 skipped, 429 warnings in 1.92s =====================================================================================
Running pytest…
/Users/ksera/.pyenv/versions/3.8.2/bin/python -m pytest --cov-report=xml --cov=/Users/ksera/github/python-slackclient/slack integration_tests/
================================================================================================= test session starts =================================================================================================
platform darwin -- Python 3.8.2, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
rootdir: /Users/ksera/github/python-slackclient, inifile: pytest.ini
plugins: cov-2.8.1
collected 34 items                                                                                                                                                                                                    

integration_tests/rtm/test_issue_530.py ss                                                                                                                                                                      [  5%]
integration_tests/rtm/test_issue_558.py s                                                                                                                                                                       [  8%]
integration_tests/rtm/test_issue_569.py s.ss                                                                                                                                                                    [ 20%]
integration_tests/rtm/test_issue_605.py s                                                                                                                                                                       [ 23%]
integration_tests/rtm/test_issue_611.py s                                                                                                                                                                       [ 26%]
integration_tests/rtm/test_issue_631.py ss                                                                                                                                                                      [ 32%]
integration_tests/rtm/test_rtm_client.py ..                                                                                                                                                                     [ 38%]
integration_tests/web/test_issue_560.py ss.                                                                                                                                                                     [ 47%]
integration_tests/web/test_issue_594.py s.                                                                                                                                                                      [ 52%]
integration_tests/web/test_issue_654.py ..                                                                                                                                                                      [ 58%]
integration_tests/web/test_web_client.py .........s....                                                                                                                                                         [100%]

================================================================================================== warnings summary ===================================================================================================
/Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/helpers.py:107
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/helpers.py:107: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
    def noop(*args, **kwargs):  # type: ignore

integration_tests/rtm/test_issue_569.py: 3 tests with warnings
integration_tests/rtm/test_rtm_client.py: 6 tests with warnings
integration_tests/web/test_issue_560.py: 2 tests with warnings
integration_tests/web/test_issue_594.py: 3 tests with warnings
integration_tests/web/test_issue_654.py: 4 tests with warnings
integration_tests/web/test_web_client.py: 38 tests with warnings
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/connector.py:964: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
    hosts = await asyncio.shield(self._resolve_host(

integration_tests/rtm/test_issue_569.py: 3 tests with warnings
integration_tests/rtm/test_rtm_client.py: 6 tests with warnings
integration_tests/web/test_issue_560.py: 2 tests with warnings
integration_tests/web/test_issue_594.py: 3 tests with warnings
integration_tests/web/test_issue_654.py: 4 tests with warnings
integration_tests/web/test_web_client.py: 38 tests with warnings
  /Users/ksera/.pyenv/versions/3.8.2/lib/python3.8/site-packages/aiohttp/locks.py:21: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.
    self._event = asyncio.Event(loop=loop)

-- Docs: https://docs.pytest.org/en/latest/warnings.html

---------- coverage: platform darwin, python 3.8.2-final-0 -----------
Coverage XML written to file coverage.xml

==================================================================================== 20 passed, 14 skipped, 113 warnings in 56.23s ====================================================================================
$ 

@seratch
Copy link
Member Author

seratch commented Apr 21, 2020

I'll merge this PR tomorrow (UTC+09:00). If you have comments or feedback, leave comments by then.

…tests

* Improve the usage of event loops in unit tests not to be affected by other tests
* Add pytest.ini for detailed logging
* Add `python setup.py run_all_tests --test-target web`
  * Add integration tests both for async/sync operations, including the reproducing case for slackapi#569
* Move samples from tests to integration_tests as they require real tokens
Now it's possible run
`python setup.py run_all_tests --integration-test-target=web/test_issue_654.py`
@seratch seratch merged commit 3fd635d into slackapi:master Apr 22, 2020
@seratch seratch deleted the more-tests branch April 22, 2020 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant