First test and mocking attempt
This commit is contained in:
parent
228364e1fb
commit
7b0545ffd3
|
@ -166,3 +166,5 @@ fabric.properties
|
|||
[Ss]cripts
|
||||
pyvenv.cfg
|
||||
pip-selfcheck.json
|
||||
|
||||
.pytest_cache/
|
|
@ -0,0 +1,2 @@
|
|||
pytest>=3.7.2,<3.8
|
||||
pytest-mock>=1.10.0,<1.11
|
|
@ -0,0 +1,21 @@
|
|||
import os
|
||||
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
|
||||
from rs500common.configuration import discover_config_file_by_name
|
||||
|
||||
|
||||
def test_discovery(monkeypatch: MonkeyPatch):
|
||||
def mock(path):
|
||||
return True
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr(os.path, 'isfile', mock)
|
||||
m.setattr(os.path, 'exists', mock)
|
||||
result = discover_config_file_by_name('test.ini', '/foo/bar')
|
||||
assert result == os.path.join('/foo/bar', 'test.ini')
|
||||
|
||||
|
||||
def test_no_hit():
|
||||
with pytest.raises(FileNotFoundError):
|
||||
discover_config_file_by_name('does-not-exist.nothing', 'bla-blubb')
|
Loading…
Reference in New Issue