Skip to content

Commit

Permalink
Correct import error (#20)
Browse files Browse the repository at this point in the history
* correct noop import (fixes #19)
* require luma.core 1.0.0 or newer
* add test for clut module
* add segment_mapper test

* add more emulator tests
  • Loading branch information
thijstriemstra authored and rm-hull committed Sep 6, 2017
1 parent c833c09 commit 0682c31
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,8 @@ ChangeLog
+------------+---------------------------------------------------------------------+------------+
| Version | Description | Date |
+============+=====================================================================+============+
| *upcoming* | * Correct ``noop`` import | |
+------------+---------------------------------------------------------------------+------------+
| **0.2.4** | * Move show/hide/contrast methods into emulator | 2017/04/30 |
| | * Add segment mapper | |
| | * Refactor tests | |
Expand Down
2 changes: 1 addition & 1 deletion luma/emulator/device.py
Expand Up @@ -17,7 +17,7 @@
from PIL import Image, ImageFont, ImageDraw

from luma.core.device import device
from luma.core.serial import noop
from luma.core.interface.serial import noop
from luma.emulator.render import transformer
from luma.emulator.clut import rgb2short
from luma.emulator.segment_mapper import regular
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -44,7 +44,7 @@ def read_file(fname):
"luma/emulator/images/7-segment.png"
]},
install_requires=[
"luma.core>=0.2.0",
"luma.core>=1.0.0",
"pygame"
],
setup_requires=pytest_runner,
Expand Down
14 changes: 14 additions & 0 deletions tests/test_clut.py
@@ -0,0 +1,14 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Richard Hull and contributors
# See LICENSE.rst for details.

"""
Tests for :py:class:`luma.emulator.clut`.
"""

from luma.emulator.clut import rgb2short


def test_rgb2short():
assert rgb2short(100, 100, 100) == 59
12 changes: 12 additions & 0 deletions tests/test_emulator.py
Expand Up @@ -23,6 +23,18 @@ def test_cleanup():
device.cleanup()


def test_show():
device = emulator(1, 2, 3, 'RGB', 'none', 6)
device.show()
assert device._contrast == 1.0


def test_hide():
device = emulator(1, 2, 3, 'RGB', 'none', 6)
device.hide()
assert device._contrast == 0.0


def test_alpha():
w, h = 100, 50
device = emulator(width=w, height=h, rotate=3, mode='RGB',
Expand Down
16 changes: 16 additions & 0 deletions tests/test_segment_mapper.py
@@ -0,0 +1,16 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Richard Hull and contributors
# See LICENSE.rst for details.

"""
Tests for :py:class:`luma.emulator.segment_mapper`.
"""

from luma.emulator.segment_mapper import regular


def test_regular():
result = [48, 109, 121, 51, 0, 127, 15, 78]
for index, val in enumerate(regular('1234 BTC')):
assert val == result[index]

0 comments on commit 0682c31

Please sign in to comment.