How to use the pyfakefs.fake_filesystem_unittest.patchfs function in pyfakefs

To help you get started, we’ve selected a few pyfakefs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tribe29 / checkmk / tests-py3 / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_disable_write_to_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()
    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}
    # End of setup.
github tribe29 / checkmk / tests-py3 / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_disable_read_to_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()
    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}
    # End of setup.
github tribe29 / checkmk / tests / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_write_and_read_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()

    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}
github tribe29 / checkmk / tests / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_disable_read_to_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()
    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}
    # End of setup.
github tribe29 / checkmk / tests / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_disable_write_to_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()
    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}
    # End of setup.
github tribe29 / checkmk / tests-py3 / unit / cmk / base / data_sources / test_snmp_data_source.py View on Github external
@patchfs
def test_write_and_read_file_cache(monkeypatch, fs):
    # Beginning of setup.
    Scenario().add_host("hostname").apply(monkeypatch)
    source = SNMPDataSource("hostname", "ipaddress")
    source.set_max_cachefile_age(999)
    source.set_may_use_cache_file()

    # Patch I/O: It is good enough to patch `store.save_file()`
    # as pyfakefs takes care of the rest.
    monkeypatch.setattr(store, "save_file",
                        lambda path, contents: fs.create_file(path, contents=contents))

    file_cache = source._make_file_cache()

    table: SNMPTable = []
    raw_data: SNMPRawData = {SectionName("X"): table}