Skip to content

ModuleNotFoundError: No module named 'py' #565

@sr-verde

Description

@sr-verde

Describe the bug
Unittest fails with ModuleNotFoundError: No module named 'py'

$ python -m unittest
E
======================================================================
ERROR: tests.utils.test_config (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: tests.utils.test_config
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/user/git/some/tests/utils/test_config.py", line 4, in <module>
    from pyfakefs.fake_filesystem_unittest import TestCase as FakeFsTestCase
  File "/home/user/git/some/venv/lib/python3.8/site-packages/pyfakefs/fake_filesystem_unittest.py", line 49, in <module>
    import py
ModuleNotFoundError: No module named 'py'

This error does not happen with PyFakeFS versions less 4.2.

How To Reproduce
Minimal example:

from pyfakefs.fake_filesystem_unittest import TestCase as FakeFsTestCase


class TestConfigReadsProperly(FakeFsTestCase):
    def setUp(self):
        self.setUpPyfakefs()

    def test_mock(self):
        pass

Your enviroment

$ python -c "import platform; print(platform.platform())"
Linux-5.9.2-arch1-1-x86_64-with-glibc2.2.5
$ python -c "import sys; print('Python', sys.version)"
Python 3.8.6 (default, Sep 30 2020, 04:00:38) 
[GCC 10.2.0]
$ python -c "from pyfakefs.fake_filesystem import __version__; print('pyfakefs', __version__)"
pyfakefs 4.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions