File: test_reload_local_import.py

package info (click to toggle)
python-pyfakefs 5.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,476 kB
  • sloc: python: 20,153; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 771 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import pytest

from pyfakefs.fake_filesystem_unittest import Patcher
from pyfakefs.fake_pathlib import FakePathlibModule
from pyfakefs.helpers import reload_cleanup_handler
from pyfakefs.pytest_tests import local_import


@pytest.fixture
def test_fs():
    with Patcher() as patcher:
        patcher.cleanup_handlers["pyfakefs.pytest_tests.lib_using_pathlib"] = (
            reload_cleanup_handler
        )
        yield patcher.fs


class TestReloadCleanupHandler:
    def test1(self, test_fs):
        path = local_import.load("some_path")
        assert isinstance(path, FakePathlibModule.Path)

    def test2(self):
        path = local_import.load("some_path")
        # will fail without reload handler
        assert not isinstance(path, FakePathlibModule.Path)