Skip to content

Commit

Permalink
Merge pull request #255 from BastianStender/bst/linting
Browse files Browse the repository at this point in the history
Bug fixes, linting, drop python3.4 and Travis rework
  • Loading branch information
jluebbe authored Jun 5, 2018
2 parents 8289085 + ed61360 commit 2933466
Show file tree
Hide file tree
Showing 107 changed files with 652 additions and 764 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
language: python
python:
- "3.4"
- "3.5"
- "3.6"
before_install:
- sudo apt-get -qq update
- sudo apt-get install -y libow-dev
install:
- pip install --upgrade setuptools
- pip install --upgrade pytest pytest-mock pytest-cov coveralls codecov
- pip install -r dev-requirements.txt
- pip install -r travis-requirements.txt
- pip install -e .
script:
- pytest --cov-config .coveragerc --cov=labgrid
- python setup.py build_sphinx
- make -C man all
- git diff
- git diff-index --quiet HEAD --
- git --no-pager diff --exit-code
after_success:
- coveralls
- codecov
1 change: 1 addition & 0 deletions crossbar-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r requirements.txt
setuptools>=38.0.0
crossbar==17.12.1
# For crossbar
idna==2.5
8 changes: 4 additions & 4 deletions examples/barebox/test_barebox.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def test_barebox(command):
stdout, stderr, returncode = command.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'barebox' in '\n'.join(stdout)

stdout, stderr, returncode = command.run('false')
assert returncode == 1
assert len(stdout) == 0
assert len(stderr) == 0
assert not stdout
assert not stderr
3 changes: 2 additions & 1 deletion examples/barebox/test_bootchooser.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import pytest


def test_bootchooser(command):
stdout, stderr, returncode = command.run('bootchooser -i')
if returncode == 127:
pytest.skip("bootchooser command not available")
assert returncode == 0
assert len(stderr) == 0
assert not stderr
assert stdout[0].startswith('Good targets')
assert stdout[1] != 'none'
8 changes: 4 additions & 4 deletions examples/barebox/test_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def test_sleep(command):
stdout, stderr, returncode = command.run('true')
elapsed_true = monotonic() - timestamp
assert returncode == 0
assert len(stdout) == 0
assert len(stderr) == 0
assert not stdout
assert not stderr

timestamp = monotonic()
stdout, stderr, returncode = command.run('sleep 1')
elapsed_sleep = monotonic() - timestamp
assert returncode == 0
assert len(stdout) == 0
assert len(stderr) == 0
assert not stdout
assert not stderr

assert elapsed_true < elapsed_sleep

Expand Down
2 changes: 1 addition & 1 deletion examples/barebox/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ def test_state(command):
if returncode == 127:
pytest.skip("state command not available")
assert returncode == 0
assert len(stderr) == 0
assert not stderr
assert stdout[0] == 'registered state instances:'
assert len(stdout) > 1
4 changes: 2 additions & 2 deletions examples/barebox/test_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ def test_watchdog(command):
if returncode == 127:
pytest.skip("wd command not available")
assert returncode == 0
assert len(stderr) == 0
assert len(stdout) == 0
assert not stderr
assert not stdout

command._await_prompt()

Expand Down
6 changes: 3 additions & 3 deletions examples/hawkbit/test_hawkbit.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import pytest
import time
import pytest

from labgrid.external import HawkbitTestClient
from labgrid.driver import InfoDriver


@pytest.fixture()
def hawkbit():
# Requires a hawkbit server instance to be running.
# See: https://github.com/eclipse/hawkbit on how to set up
# a test instance of hawkbit
client = HawkbitTestClient("localhost", "8080", "admin", "admin")
assert(isinstance(client, HawkbitTestClient))
assert isinstance(client, HawkbitTestClient)
return client

def test_upgrade(hawkbit):
Expand Down
3 changes: 2 additions & 1 deletion examples/library/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"""Power-cycle a target until the /dev/nand0 device is missing."""

import sys
import logging

from labgrid import Environment, StepReporter
from labgrid.strategy.bareboxstrategy import Status


# enable debug logging
import logging
logging.basicConfig(
level=logging.DEBUG,
format='%(levelname)7s: %(message)s',
Expand Down
8 changes: 4 additions & 4 deletions examples/remote/test_barebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ def test_target(target):

stdout, stderr, returncode = barebox.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'barebox' in '\n'.join(stdout)

stdout, stderr, returncode = barebox.run('false')
assert returncode == 1
assert len(stdout) == 0
assert len(stderr) == 0
assert not stdout
assert not stderr
1 change: 0 additions & 1 deletion examples/shell/test_hwclock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time
from datetime import datetime


Expand Down
8 changes: 4 additions & 4 deletions examples/shell/test_shell.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
def test_shell(command):
stdout, stderr, returncode = command.run('cat /proc/version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'Linux' in stdout[0]

stdout, stderr, returncode = command.run('false')
assert returncode != 0
assert len(stdout) == 0
assert len(stderr) == 0
assert not stdout
assert not stderr
2 changes: 1 addition & 1 deletion examples/strategy/bareboxrebootstrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Status(enum.Enum):
@attr.s(cmp=False)
class BareboxRebootStrategy(Strategy):
"""A Strategy to switch to barebox or shell and back via reboot
In your env.yaml, simply instantiate the strategy without parameters, for example:
.. code-block:: yaml
Expand Down
10 changes: 6 additions & 4 deletions examples/strategy/test_barebox_strategy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from labgrid.exceptions import NoDriverFoundError


@pytest.fixture()
def strategy(target):
Expand All @@ -26,8 +28,8 @@ def test_barebox(target, in_bootloader):

stdout, stderr, returncode = command.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'barebox' in '\n'.join(stdout)


Expand All @@ -36,8 +38,8 @@ def test_shell(target, in_shell):
command = target['ShellDriver']
stdout, stderr, returncode = command.run('cat /proc/version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'Linux' in stdout[0]


Expand Down
15 changes: 7 additions & 8 deletions examples/strategy/test_uboot_strategy.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pytest
import logging


@pytest.fixture()
def strategy(target):
try:
return target.get_driver('UBootStrategy')
except:
except NoDriverFoundError:
pytest.skip("strategy not found")


Expand All @@ -28,8 +27,8 @@ def test_uboot(target, in_bootloader):

stdout, stderr, returncode = command.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'U-Boot' in '\n'.join(stdout)


Expand All @@ -38,8 +37,8 @@ def test_shell(target, in_shell):
command = target.get_driver('ShellDriver')
stdout, stderr, returncode = command.run('cat /proc/version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'Linux' in stdout[0]


Expand All @@ -48,6 +47,6 @@ def test_uboot_2(target, in_bootloader):

stdout, stderr, returncode = command.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'U-Boot' in '\n'.join(stdout)
1 change: 0 additions & 1 deletion examples/usb/test_usb_mxs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ def test_usb(target):
def test_mxs_load(target):
bp = target.get_driver('BootstrapProtocol')
bp.load()

7 changes: 3 additions & 4 deletions examples/usbpower/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
from labgrid.resource import USBPowerPort
from labgrid.driver import USBPowerDriver


t = Target(name='main')
upp = USBPowerPort(t,
name=None,
match={'ID_PATH': 'pci-0000:00:14.0-usb-0:2:1.0'},
index=1)
upp = USBPowerPort(t, name=None,
match={'ID_PATH': 'pci-0000:00:14.0-usb-0:2:1.0'}, index=1)
upd = USBPowerDriver(t, name=None)

t.activate(upd)
Expand Down
10 changes: 6 additions & 4 deletions examples/usbpower/test_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from labgrid.exceptions import NoDriverFoundError


@pytest.fixture()
def strategy(target):
Expand All @@ -26,16 +28,16 @@ def shell(target, strategy, capsys):
def test_barebox(bootloader):
stdout, stderr, returncode = bootloader.run('version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'barebox' in '\n'.join(stdout)


def test_shell(shell):
stdout, stderr, returncode = shell.run('cat /proc/version')
assert returncode == 0
assert len(stdout) > 0
assert len(stderr) == 0
assert stdout
assert not stderr
assert 'Linux' in stdout[0]


Expand Down
Loading

0 comments on commit 2933466

Please sign in to comment.