summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2020-10-04 20:51:50 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2020-10-04 21:22:14 +0200
commit2da7720c565f560816a16462eeb6134e9741ee64 (patch)
tree2a621f8278fd3a41f3220d856fbe15379d0f32af
parentAdd missing py.typed files to package. (diff)
downloadfreestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar.gz
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar.bz2
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar.lz
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar.xz
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.tar.zst
freestyle-hid-2da7720c565f560816a16462eeb6134e9741ee64.zip
-rw-r--r--.travis.yml20
-rw-r--r--freestyle_hid/tests/__init__.py3
-rw-r--r--freestyle_hid/tests/test_freestyle.py22
-rw-r--r--pyproject.toml11
-rw-r--r--setup.cfg3
5 files changed, 59 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f219e0d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,20 @@
+# SPDX-FileCopyrightText: 2013 The freestyle-hid Authors
+#
+# SPDX-License-Identifier: 0BSD
+
+dist: xenial
+
+language: python
+
+matrix:
+ include:
+ - python: 3.7
+ - python: 3.8
+ env: PYTEST_OPTIONS="--mypy"
+ - python: 3.9-dev
+
+install:
+ - pip install .[dev]
+
+script:
+ - pytest $PYTEST_OPTIONS
diff --git a/freestyle_hid/tests/__init__.py b/freestyle_hid/tests/__init__.py
new file mode 100644
index 0000000..3e0558f
--- /dev/null
+++ b/freestyle_hid/tests/__init__.py
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: 2013 The freestyle-hid Authors
+#
+# SPDX-License-Identifier: 0BSD
diff --git a/freestyle_hid/tests/test_freestyle.py b/freestyle_hid/tests/test_freestyle.py
new file mode 100644
index 0000000..feb7c15
--- /dev/null
+++ b/freestyle_hid/tests/test_freestyle.py
@@ -0,0 +1,22 @@
+# SPDX-FileCopyrightText: © 2019 The freestyle-hid Authors
+# SPDX-License-Identifier: Apache-2.0
+"""Tests for the common FreeStyle functions.."""
+
+# pylint: disable=protected-access,missing-docstring
+
+import unittest
+
+from freestyle_hid import _session
+
+
+class TestFreeStyle(unittest.TestCase):
+ def test_outgoing_command(self):
+ """Test the generation of a new outgoing message."""
+
+ self.assertEqual(
+ b"\0\x17\7command\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
+ b"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
+ _session._FREESTYLE_MESSAGE.build(
+ {"message_type": 23, "command": b"command"}
+ ),
+ )
diff --git a/pyproject.toml b/pyproject.toml
index e6eedfe..a062cb5 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -42,3 +42,14 @@ known_first_party = ['glucometerutils']
known_third_party = ['construct', 'hidapi', 'pyscsi', 'serial', 'usbmon']
[tool.setuptools_scm]
+
+[tool.pytest.ini_options]
+addopts = "--color=yes --ignore=setup.py -ra"
+timeout = 120
+norecursedirs = [
+ '.env',
+ '.git',
+ 'dist',
+ 'build',
+ 'venv',
+]
diff --git a/setup.cfg b/setup.cfg
index 6b7fa64..31f766c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -46,6 +46,9 @@ tools =
dev =
mypy
pre-commit
+ pytest-mypy
+ pytest-timeout>=1.3.0
+ pytest>=6.0
setuptools_scm
[options.package_data]