Made Python files compliant with PEP8, except for E501

This commit is contained in:
Paulo Martinez 2017-04-12 09:39:36 +02:00
parent 4c8ce14dad
commit 10925659ef
3 changed files with 233 additions and 240 deletions

View File

@ -1,14 +1,13 @@
import unittest
import settings
import time
import mosquitto
import serial
def on_message(mosq, obj, msg):
obj.message_queue.append(msg)
class mqtt_basic(unittest.TestCase):
message_queue = []
@ -38,6 +37,3 @@ class mqtt_basic(unittest.TestCase):
self.assertEqual(msg.payload, "hello world")
self.assertEqual(msg.qos, 0, "message qos not 0")
self.assertEqual(msg.retain, False, "message retain flag incorrect")

View File

@ -1,14 +1,13 @@
import unittest
import settings
import time
import mosquitto
import serial
def on_message(mosq, obj, msg):
obj.message_queue.append(msg)
class mqtt_publish_in_callback(unittest.TestCase):
message_queue = []
@ -39,7 +38,6 @@ class mqtt_publish_in_callback(unittest.TestCase):
self.assertEqual(msg.qos, 0, "message qos not 0")
self.assertEqual(msg.retain, False, "message retain flag incorrect")
def test_publish(self):
self.assertEqual(len(self.message_queue), 0, "message queue not empty")
payload = "abcdefghij"
@ -59,6 +57,3 @@ class mqtt_publish_in_callback(unittest.TestCase):
self.assertEqual(msg.payload, payload)
self.assertEqual(msg.qos, 0, "message qos not 0")
self.assertEqual(msg.retain, False, "message retain flag incorrect")

View File

@ -10,21 +10,22 @@ import re
from testcases import settings
class Workspace(object):
def __init__(self):
self.root_dir = os.getcwd()
self.build_dir = os.path.join(self.root_dir,"tmpbin");
self.log_dir = os.path.join(self.root_dir,"logs");
self.tests_dir = os.path.join(self.root_dir,"testcases");
self.build_dir = os.path.join(self.root_dir, "tmpbin")
self.log_dir = os.path.join(self.root_dir, "logs")
self.tests_dir = os.path.join(self.root_dir, "testcases")
self.examples_dir = os.path.join(self.root_dir, "../PubSubClient/examples")
self.examples = []
self.tests = []
if not os.path.isdir("../PubSubClient"):
raise Exception("Cannot find PubSubClient library")
try:
import ino
except:
return __import__('ino')
except ImportError:
raise Exception("ino tool not installed")
def init(self):
@ -57,6 +58,7 @@ class Workspace(object):
def clean(self):
shutil.rmtree(self.build_dir)
class Sketch(object):
def __init__(self, wksp, fn):
self.w = wksp
@ -100,7 +102,7 @@ class Sketch(object):
sys.stdout.write("\n")
with open(self.build_err_log) as f:
for line in f:
print " ",line,
print(" " + line)
return False
def upload(self):
@ -118,10 +120,9 @@ class Sketch(object):
sys.stdout.write("\n")
with open(self.build_upload_log) as f:
for line in f:
print " ",line,
print(" " + line)
return False
def test(self):
# import the matching test case, if it exists
try:
@ -146,19 +147,20 @@ class Sketch(object):
sys.stdout.flush()
for t in tests:
t.run(result)
print "%d/%d"%(result.testsRun-len(result.failures)-len(result.errors),result.testsRun)
print(str(result.testsRun - len(result.failures) - len(result.errors)) + "/" + str(result.testsRun))
if not result.wasSuccessful():
if len(result.failures) > 0:
for f in result.failures:
print "-- %s"%(str(f[0]),)
print f[1]
print("-- " + str(f[0]))
print(f[1])
if len(result.errors) > 0:
print " Errors:"
print(" Errors:")
for f in result.errors:
print "-- %s"%(str(f[0]),)
print f[1]
print("-- " + str(f[0]))
print(f[1])
c.tearDownClass()
if __name__ == '__main__':
run_tests = True
@ -166,13 +168,13 @@ if __name__ == '__main__':
w.init()
for e in w.examples:
print "--------------------------------------"
print "[%s]"%(e.basename,)
print("--------------------------------------")
print("[" + e.basename + "]")
if e.build() and run_tests:
e.test()
for e in w.tests:
print "--------------------------------------"
print "[%s]"%(e.basename,)
print("--------------------------------------")
print("[" + e.basename + "]")
if e.build() and run_tests:
e.test()