From cdd7167e240e8e8b909864ec1faa32b942af30b1 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 3 Apr 2015 17:42:00 +0300 Subject: [PATCH] Improve firmware detecting for system tests --- .isort.cfg | 2 +- tests/test_examples.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.isort.cfg b/.isort.cfg index c905e9ca..72280366 100644 --- a/.isort.cfg +++ b/.isort.cfg @@ -1,3 +1,3 @@ [settings] line_length=79 -known_third_party=click,requests,serial,SCons +known_third_party=click,requests,serial,SCons,pytest diff --git a/tests/test_examples.py b/tests/test_examples.py index 2677ccfc..9ababba2 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,6 +1,7 @@ # Copyright (C) Ivan Kravets # See LICENSE for details. +from glob import glob from os import listdir, walk from os.path import dirname, getsize, isdir, isfile, join, normpath from shutil import rmtree @@ -39,12 +40,11 @@ def test_run(platformio_setup, pioproject_dir): pioenvs_dir = join(pioproject_dir, ".pioenvs") for item in listdir(pioenvs_dir): assert isfile(join(pioenvs_dir, item, "firmware.elf")) - # check .hex or .bin file - bin_file = join(pioenvs_dir, item, "firmware.bin") - hex_file = join(pioenvs_dir, item, "firmware.hex") - if not isfile(bin_file): - if not isfile(hex_file): - pytest.fail("Missed firmware file") - assert getsize(hex_file) > 0 - else: - assert getsize(bin_file) > 0 + # check .hex or .bin files + firmwares = [] + for ext in ("bin", "hex"): + firmwares += glob(join(pioenvs_dir, item, "firmware*.%s" % ext)) + if not firmwares: + pytest.fail("Missed firmware file") + for firmware in firmwares: + assert getsize(firmware) > 0