Skip to content

Commit

Permalink
Auto close fetcher session
Browse files Browse the repository at this point in the history
  • Loading branch information
alfinkel committed Aug 31, 2020
1 parent e256d2f commit b010188
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# UNRELEASED

- [FIXED] ComplianceFetcher session object is auto-closed now in tearDownClass.

# 1.2.7

- [CHANGED] Removed PyYAML dependency to resolve downstream dependency issues.
Expand Down
6 changes: 5 additions & 1 deletion compliance/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
class ComplianceFetcher(unittest.TestCase):
"""Compliance fetcher automation TestCase class."""

_multiprocess_can_split_ = True
@classmethod
def tearDownClass(cls):
"""Perform clean up."""
if hasattr(cls, '_session'):
cls._session.close()

@classmethod
def session(cls, url=None, creds=None, **headers):
Expand Down
6 changes: 3 additions & 3 deletions test/t_compliance/t_fetch/test_base_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def setUp(self):
# unittest.TestCase, we must pass a method in the
# constructor (otherwise, we will get a ValueError). Since we
# don't need this method, passing ``__doc__`` is enough for
# building a ComplianceCheck object successfully.
self.check = ComplianceFetcher('__doc__')
# building a ComplianceFetcher object successfully.
self.fetcher = ComplianceFetcher('__doc__')

def test_config(self):
"""Check that the config property returns a ComplianceConfig object."""
self.assertIsInstance(self.check.config, ComplianceConfig)
self.assertIsInstance(self.fetcher.config, ComplianceConfig)

0 comments on commit b010188

Please sign in to comment.