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

suppress ResourceWarning when running tests #364

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/test_facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import os
import unittest
import inspect
import warnings

try:
from urllib.parse import parse_qs, urlencode, urlparse
Expand All @@ -32,6 +33,19 @@ class FacebookTestCase(unittest.TestCase):

"""
def setUp(self):

# Due to a python requests design choice, there's this warning
# about an unclosed connection when running the tests.
# https://github.com/kennethreitz/requests/issues/3912
# This can be annoying when running the tests, hence this filter to
# suppress the warning as discussed in
# https://github.com/kennethreitz/requests/issues/1882

super().setUp()
warnings.filterwarnings(action="ignore",
message="unclosed",
category=ResourceWarning)

try:
self.app_id = os.environ["FACEBOOK_APP_ID"]
self.secret = os.environ["FACEBOOK_SECRET"]
Expand All @@ -42,6 +56,12 @@ def setUp(self):
self.test_users = []

def tearDown(self):

super().tearDown()
warnings.filterwarnings(action="ignore",
message="unclosed",
category=ResourceWarning)

"""Deletes the test users included in the test user list."""
token = facebook.GraphAPI().get_app_access_token(
self.app_id, self.secret)
Expand Down