Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #356 from NordicSemiconductor/fix/migrate-to-39
Browse files Browse the repository at this point in the history
Fix/migrate to 39
  • Loading branch information
jornbh authored Aug 23, 2021
2 parents af139f1 + d9bb2df commit fd58570
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ nrfutil.egg-info/
/tests/test.zip
.eggs/
unittests.xml


# Ignore vscode settings and debug-options
.vscode/
8 changes: 5 additions & 3 deletions nordicsemi/utility/target_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ def get_targets(self):
self.targets = []

for key, value in os.environ.items():
match = re.match(r"NORDICSEMI_TARGET_(?P<target>\d+)_(?P<key>[a-zA-Z_]+)", key)
match = re.match(
r"NORDICSEMI_TARGET_(?P<target>\d+)_(?P<key>[a-zA-Z_]+)", key
)

if match:
key_value = match.groupdict()
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion nordicsemi/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@

""" Version definition for nrfutil. """

NRFUTIL_VERSION = "6.1.0"
NRFUTIL_VERSION = "6.1.1"
24 changes: 11 additions & 13 deletions requirements-frozen.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand All @@ -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={
Expand Down
12 changes: 6 additions & 6 deletions tests/bdd/steps/dfu_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}


Expand Down Expand Up @@ -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])
Expand All @@ -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.


Expand All @@ -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")
Expand All @@ -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.
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.
14 changes: 14 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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',
Expand Down

0 comments on commit fd58570

Please sign in to comment.