From eff4ca70fb1ba7de09f5fb077d45befd701c1c01 Mon Sep 17 00:00:00 2001 From: mrbean-bremen Date: Mon, 2 Nov 2020 15:08:21 +0100 Subject: [PATCH] Remove dependency of pyfakefs on pytest - fixes #565 --- CHANGES.md | 8 ++++++++ pyfakefs/fake_filesystem_unittest.py | 13 +++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d2ce0835..dfd94726 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,14 @@ The released versions correspond to PyPi releases. ## Version 4.3.0 (as yet unreleased) +## [Version 4.2.1](https://pypi.python.org/pypi/pyfakefs/4.2.1) + +This is a bugfix releases that fixes a regression issue. + +### Fixes + * remove dependency of pyfakefs on `pytest` (regression, + see [#565](../../issues/565)) + ## [Version 4.2.0](https://pypi.python.org/pypi/pyfakefs/4.2.0) #### New Features diff --git a/pyfakefs/fake_filesystem_unittest.py b/pyfakefs/fake_filesystem_unittest.py index 9871c8b4..05845aa7 100644 --- a/pyfakefs/fake_filesystem_unittest.py +++ b/pyfakefs/fake_filesystem_unittest.py @@ -46,9 +46,6 @@ import unittest import warnings -import py -import pytest - from pyfakefs.deprecator import Deprecator from pyfakefs.fake_filesystem import set_uid, set_gid, reset_ids, PatchMode from pyfakefs.helpers import IS_PYPY @@ -354,8 +351,16 @@ class Patcher: ''' SKIPMODULES = { None, fake_filesystem, fake_filesystem_shutil, - sys, linecache, tokenize, py, pytest + sys, linecache, tokenize } + try: + import py + import pytest + SKIPMODULES.add(py) + SKIPMODULES.add(pytest) + except ImportError: + pass + assert None in SKIPMODULES, ("sys.modules contains 'None' values;" " must skip them.")