Skip to content

Commit 70d6deb

Browse files
committed
Various tidy ups and creation of comments / docs.
1 parent 4402225 commit 70d6deb

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ dist
1212
**/*.egg-info
1313
.vscode
1414
.coverage
15+
*.swp

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Introduction
1616
This library provides simple byte and string based inter-device communication
1717
via BLE.
1818

19-
It works like a walkie-talkie: you can configure your device to a certain
20-
channel (numbered 0-255, default being 7) and your device will broadcast on
21-
that channel and receive any messages from other devices using that channel.
19+
It works like a walkie-talkie: configure your device to use a certain channel
20+
(numbered 0-255, default being 42) and it will broadcast on that channel and
21+
receive any messages from other devices using that channel.
2222

2323
Dependencies
2424
=============

adafruit_radio.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
2929
* Author(s): Nicholas H.Tollervey for Adafruit Industries
3030
31-
Implementation Notes
32-
--------------------
33-
3431
**Hardware:**
3532
3633
Adafruit Feather nRF52840 Express <https://www.adafruit.com/product/4062>

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# Uncomment the below if you use native CircuitPython modules such as
2121
# digitalio, micropython and busio. List the modules you use. Without it, the
2222
# autodoc module docs will fail to generate with a warning.
23-
# autodoc_mock_imports = ["digitalio", "busio"]
23+
autodoc_mock_imports = ["digitalio", "busio", "adafruit_ble"]
2424

2525

2626
intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)}

docs/index.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@ Table of Contents
2323
.. toctree::
2424
:caption: Tutorials
2525

26-
.. todo:: Add any Learn guide links here. If there are none, then simply delete this todo and leave
27-
the toctree above for use later.
28-
2926
.. toctree::
3027
:caption: Related Products
3128

32-
.. todo:: Add any product links here. If there are none, then simply delete this todo and leave
33-
the toctree above for use later.
34-
3529
.. toctree::
3630
:caption: Other Links
3731

tests/conftest.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
"""
2+
This file ensures everything is in place to run PyTest based unit tests against
3+
the adafruit_radio module. It works by using Python's mock library to add
4+
MagicMock objects to sys.modules for the modules which are not available to
5+
standard Python because they're CircuitPython only modules.
6+
7+
Such mocking happens as soon as this conftest.py file is imported (so the
8+
mocked modules exist in sys.modules before the module to be tested is
9+
imported), and immediately before each test function is evaluated (so changes
10+
to state remain isolated between tests).
11+
"""
112
import sys
213
from unittest.mock import MagicMock
314

4-
5-
# Could this be taken from a configuration setting..?
15+
# Add fully qualified namespace paths to things that are imported, but which
16+
# should be mocked away. For instance, modules which are available in
17+
# CircuitPython but not standard Python.
618
MOCK_MODULES = [
719
"adafruit_ble.BLERadio",
820
"adafruit_ble.advertising.adafruit.AdafruitRadio",
@@ -11,7 +23,8 @@
1123

1224
def mock_imported_modules():
1325
"""
14-
Mocks away the modules named in MOCK_MODULES.
26+
Mocks away the modules named in MOCK_MODULES, so the module under test
27+
can be imported with modules which may not be available.
1528
"""
1629
module_paths = set()
1730
for m in MOCK_MODULES:
@@ -26,11 +39,13 @@ def mock_imported_modules():
2639

2740
def pytest_runtest_setup(item):
2841
"""
42+
Called immediately before any test function is called.
43+
2944
Recreates afresh the mocked away modules so state between tests remains
3045
isolated.
3146
"""
3247
mock_imported_modules()
3348

3449

35-
# Needed to stop ImportError when importing module under test.
50+
# Initial mocking needed to stop ImportError when importing module under test.
3651
mock_imported_modules()

0 commit comments

Comments
 (0)