diff --git a/.gitignore b/.gitignore index 69ca7d6..f3f1ad8 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ nrfutil.egg-info/ /tests/test.zip .eggs/ unittests.xml + + +# Ignore vscode settings and debug-options +.vscode/ \ No newline at end of file diff --git a/nordicsemi/utility/target_registry.py b/nordicsemi/utility/target_registry.py index 44cb7b4..c6c1e5f 100644 --- a/nordicsemi/utility/target_registry.py +++ b/nordicsemi/utility/target_registry.py @@ -71,7 +71,9 @@ def get_targets(self): self.targets = [] for key, value in os.environ.items(): - match = re.match(r"NORDICSEMI_TARGET_(?P\d+)_(?P[a-zA-Z_]+)", key) + match = re.match( + r"NORDICSEMI_TARGET_(?P\d+)_(?P[a-zA-Z_]+)", key + ) if match: key_value = match.groupdict() @@ -102,8 +104,8 @@ def __init__(self, filename): def get_targets(self): if not self.targets: - self.targets = json.load(open(self.filename, "r"))["targets"] - + with open(self.filename, "r") as f: + self.targets = json.load(f)["targets"] return self.targets def get_target(self, target_id): diff --git a/nordicsemi/version.py b/nordicsemi/version.py index f35b9b8..5594ceb 100644 --- a/nordicsemi/version.py +++ b/nordicsemi/version.py @@ -37,4 +37,4 @@ """ Version definition for nrfutil. """ -NRFUTIL_VERSION = "6.1.0" +NRFUTIL_VERSION = "6.1.1" diff --git a/requirements-frozen.txt b/requirements-frozen.txt index 8c989e7..294f638 100644 --- a/requirements-frozen.txt +++ b/requirements-frozen.txt @@ -1,15 +1,13 @@ -antlib==1.1b0.post0 ; sys_platform == 'win32' -Click==7.0 +antlib==1.1b1 +click==8.0.1 crcmod==1.7 -ecdsa==0.13.3 -intelhex==2.2.1 -ipaddress==1.0.22 -libusb1==1.7.1 -pc-ble-driver-py==0.14.2 +ecdsa==0.17.0 +intelhex==2.3.0 +libusb1==1.9.3 +pc-ble-driver-py==0.16.1 piccata==2.0.1 -protobuf==3.10.0 -pyserial==3.4 -pyspinel==1.0.0a3 -PyYAML==5.1.2 -tqdm==4.36.1 -wrapt==1.11.2 +protobuf==3.17.3 +pyserial==3.5 +pyspinel==1.0.3 +PyYAML==5.4.1 +tqdm==4.62.0 diff --git a/requirements.txt b/requirements.txt index 600c83e..c60ab9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,7 @@ crcmod ecdsa intelhex libusb1 -pc_ble_driver_py >= 0.14.2 +pc_ble_driver_py >= 0.16.1 piccata protobuf pyserial diff --git a/setup.py b/setup.py index 384f277..ffba217 100644 --- a/setup.py +++ b/setup.py @@ -148,7 +148,7 @@ def run_tests(self): '../libusb/x86/libusb-1.0.dll', '../libusb/x64/libusb-1.0.dll', '../libusb/x64/libusb-1.0.dylib', '../libusb/LICENSE'] }, - python_requires='>=3.6, <3.9', + python_requires='>=3.7, <3.10', install_requires=reqs, zipfile=None, tests_require=[ @@ -171,9 +171,9 @@ def run_tests(self): 'License :: Other/Proprietary License', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', ], keywords='nordic nrf51 nrf52 ble bluetooth dfu ota softdevice serialization nrfutil pc-nrfutil', cmdclass={ diff --git a/tests/bdd/steps/dfu_steps.py b/tests/bdd/steps/dfu_steps.py index 1a90539..9c37837 100644 --- a/tests/bdd/steps/dfu_steps.py +++ b/tests/bdd/steps/dfu_steps.py @@ -55,7 +55,7 @@ all_boards = { 'PCA10056': DeviceLister().get_device(get_all=True, vendor_id='1366'), 'PCA10059': DeviceLister().get_device(get_all=True, vendor_id='1915') -} +} boards = {} @@ -239,7 +239,7 @@ def step_impl(context, image, image_type, board): snr = str(int(os.environ[board])) # Remove zeros to the left. else: snr = boards[board].serial_number.lower().lstrip('0') - + if image_type == "usb-serial": port = program_image_usb_serial(context, nrfjprog, full_image_path, snr) context.args.extend(['-p', port]) @@ -263,7 +263,7 @@ def step_impl(context, nrfutil): result = context.runner.invoke(nrfutil, context.args) logger.debug("exit_code: %s, output: \'%s\'", result.exit_code, result.output) - assert result.exit_code == 0 + assert result.exit_code == 0, "exit_code: {}, output: \'{}\'".format( result.exit_code, result.output) time.sleep(ENUMERATE_WAIT_TIME) # Waiting some time to ensure enumeration before next test. @@ -275,7 +275,7 @@ def step_impl(context): result = context.runner.invoke(cli, context.args) logger.debug("exit_code: %s, output: \'%s\'", result.exit_code, result.output) - assert result.exit_code == 0 + assert result.exit_code == 0, "exit_code: {}, output: \'{}\'".format( result.exit_code, result.output) time.sleep(ENUMERATE_WAIT_TIME) # Waiting for device to enumerate devices_after_programming = lister.get_device(get_all=True, vendor_id="1915", product_id="C00A") @@ -297,5 +297,5 @@ def step_impl(context): context.args[-1] = port result = context.runner.invoke(cli, context.args) logger.debug("exit_code: %s, output: \'%s\'", result.exit_code, result.output) - assert result.exit_code == 0 - time.sleep(ENUMERATE_WAIT_TIME) # Waiting some time to ensure enumeration before next test. \ No newline at end of file + assert result.exit_code == 0, "exit_code: {}, output: \'{}\'".format( result.exit_code, result.output) + time.sleep(ENUMERATE_WAIT_TIME) # Waiting some time to ensure enumeration before next test. diff --git a/tests/test_cli.py b/tests/test_cli.py index 4cf143d..11241f0 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,3 +1,10 @@ +""" +The tests seems to work with `python -m unittest`, but not by being called directly from the CLI +The setUp is called twice, and crashes when being asked to do a `cd ./tests` for a second time +Look into a cleanup function + +The behavior is inconsistent between 3.9 and 3.7 (3.7 fails) +""" import os import unittest from click.testing import CliRunner @@ -7,12 +14,19 @@ class TestManifest(unittest.TestCase): runner = CliRunner() cli = __main__.cli + original_path = os.path.abspath(os.path.curdir) def setUp(self): script_abspath = os.path.abspath(__file__) script_dirname = os.path.dirname(script_abspath) + self.original_path = os.path.abspath(os.path.curdir) # Make it possible to go back os.chdir(script_dirname) + def tearDown(self) -> None: + """ + Go back to the old dir + """ + os.chdir(self.original_path) def test_pkg_gen(self): result = self.runner.invoke(self.cli, ['pkg', 'generate',