From 9b01129a809a91873a1f2c0e2bb4bcb1e52a0c1e Mon Sep 17 00:00:00 2001 From: Soban Javed Date: Wed, 13 May 2020 18:01:16 +0500 Subject: [PATCH] fix py38 travis worker removed unittest.mock's _is_started() compatibility for pyhton 3.5 unittest.mock's _is_started() removed allow_failures from python 3.8 travis workers --- .travis.yml | 4 ---- .../courses/tests/test_views/__init__.py | 13 ++++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b4bfcee4..544d6131d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,10 +58,6 @@ matrix: env: TESTNAME=test-python-38 TARGETS="PYTHON_ENV=py38 requirements.js test_python" - allow_failures: - - python: 3.8 - - after_failure: # Print the list of running containers to rule out a killed container as a cause of failure diff --git a/analytics_dashboard/courses/tests/test_views/__init__.py b/analytics_dashboard/courses/tests/test_views/__init__.py index dcfd18e72..0e0625371 100644 --- a/analytics_dashboard/courses/tests/test_views/__init__.py +++ b/analytics_dashboard/courses/tests/test_views/__init__.py @@ -3,7 +3,7 @@ import json import logging -from unittest.mock import _is_started, Mock, patch +from unittest.mock import Mock, patch import httpretty from analyticsclient.exceptions import NotFoundError from ddt import data, ddt @@ -343,8 +343,15 @@ def start_patching(self): _patch.start() def stop_patching(self): - for _patch in self.patches: - if _is_started(_patch): + # TODO: Just for the compatibility with python 3.5. + # Can be removed once support is dropped + try: + from unittest.mock import _is_started # pylint: disable=import-outside-toplevel + for _patch in self.patches: + if _is_started(_patch): + _patch.stop() + except ImportError: + for _patch in self.patches: _patch.stop() def clear_patches(self):