Skip to content

Commit 55922ea

Browse files
committed
tests: setup test infrastructure
Setup test infrastructure, populate it with a simple test of get_systemd_version function. Signed-off-by: Adam Trhon <[email protected]>
1 parent b2c745d commit 55922ea

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/build
22
*.egg-info
33
__pycache__
4+
.tox
5+
*.eggs/README.txt

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
labgrid

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
3+
from labgrid.driver.fake import FakeCommandDriver
4+
from labgrid import Target
5+
6+
7+
@pytest.fixture
8+
def command():
9+
t = Target("dummy")
10+
d = FakeCommandDriver(t, "command")
11+
t.activate(d)
12+
return d

tests/test_linux.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from labgridhelper import linux
2+
3+
def test_get_systemd_version(command, monkeypatch):
4+
systemd_version = 'systemd 249 (249.5-2-arch)\n+PAM +AUDIT -SELINUX\n'
5+
6+
monkeypatch.setattr(command, 'run_check', lambda cmd: [systemd_version])
7+
8+
assert linux.get_systemd_version(command) == 249

tox.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[tox]
2+
envlist = py35, py36, py37
3+
4+
[testenv]
5+
deps = -rdev-requirements.txt
6+
commands = pytest tests {posargs}

0 commit comments

Comments
 (0)