mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-06-02 00:21:05 +03:00
tests: journal_lock: Fix test_journal_lock_init test
* It's `tmp_path_factory` now, not `tmpdir_factory`. * Need to `str(...)` if a string is what we want.
This commit is contained in:
parent
cc37b23db4
commit
b47f278655
@ -110,45 +110,45 @@ class TestJournalLock:
|
|||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_journaldir(
|
def mock_journaldir(
|
||||||
self, monkeypatch: _pytest_monkeypatch,
|
self, monkeypatch: _pytest_monkeypatch,
|
||||||
tmpdir_factory: _pytest_tmpdir.TempPathFactory
|
tmp_path_factory: _pytest_tmpdir.TempPathFactory
|
||||||
) -> py_path_local_LocalPath:
|
) -> py_path_local_LocalPath:
|
||||||
"""Fixture for mocking config.get_str('journaldir')."""
|
"""Fixture for mocking config.get_str('journaldir')."""
|
||||||
def get_str(key: str, *, default: str = None) -> str:
|
def get_str(key: str, *, default: str = None) -> str:
|
||||||
"""Mock config.*Config get_str to provide fake journaldir."""
|
"""Mock config.*Config get_str to provide fake journaldir."""
|
||||||
if key == 'journaldir':
|
if key == 'journaldir':
|
||||||
return tmpdir_factory
|
return str(tmp_path_factory)
|
||||||
|
|
||||||
print('Other key, calling up ...')
|
print('Other key, calling up ...')
|
||||||
return config.get_str(key) # Call the non-mocked
|
return config.get_str(key) # Call the non-mocked
|
||||||
|
|
||||||
with monkeypatch.context() as m:
|
with monkeypatch.context() as m:
|
||||||
m.setattr(config, "get_str", get_str)
|
m.setattr(config, "get_str", get_str)
|
||||||
yield tmpdir_factory
|
yield tmp_path_factory
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_journaldir_changing(
|
def mock_journaldir_changing(
|
||||||
self,
|
self,
|
||||||
monkeypatch: _pytest_monkeypatch,
|
monkeypatch: _pytest_monkeypatch,
|
||||||
tmpdir_factory: _pytest_tmpdir.TempPathFactory
|
tmp_path_factory: _pytest_tmpdir.TempPathFactory
|
||||||
) -> py_path_local_LocalPath:
|
) -> py_path_local_LocalPath:
|
||||||
"""Fixture for mocking config.get_str('journaldir')."""
|
"""Fixture for mocking config.get_str('journaldir')."""
|
||||||
def get_str(key: str, *, default: str = None) -> str:
|
def get_str(key: str, *, default: str = None) -> str:
|
||||||
"""Mock config.*Config get_str to provide fake journaldir."""
|
"""Mock config.*Config get_str to provide fake journaldir."""
|
||||||
if key == 'journaldir':
|
if key == 'journaldir':
|
||||||
return tmpdir_factory.mktemp("changing")
|
return tmp_path_factory.mktemp("changing")
|
||||||
|
|
||||||
print('Other key, calling up ...')
|
print('Other key, calling up ...')
|
||||||
return config.get_str(key) # Call the non-mocked
|
return config.get_str(key) # Call the non-mocked
|
||||||
|
|
||||||
with monkeypatch.context() as m:
|
with monkeypatch.context() as m:
|
||||||
m.setattr(config, "get_str", get_str)
|
m.setattr(config, "get_str", get_str)
|
||||||
yield tmpdir_factory
|
yield tmp_path_factory
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Tests against JournalLock.__init__()
|
# Tests against JournalLock.__init__()
|
||||||
def test_journal_lock_init(self, mock_journaldir: py_path_local_LocalPath):
|
def test_journal_lock_init(self, mock_journaldir: py_path_local_LocalPath):
|
||||||
"""Test JournalLock instantiation."""
|
"""Test JournalLock instantiation."""
|
||||||
tmpdir = mock_journaldir
|
tmpdir = str(mock_journaldir)
|
||||||
|
|
||||||
jlock = JournalLock()
|
jlock = JournalLock()
|
||||||
# Check members are properly initialised.
|
# Check members are properly initialised.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user