[riot-notifications] [RIOT-OS/RIOT] tests: add tests to reproduce #10881 (#10908)

Martine Lenders notifications at github.com
Fri Feb 1 09:28:36 CET 2019


miri64 commented on this pull request.



> +# Copyright (C) 2019 Freie Universit├Ąt Berlin
+#
+# This file is subject to the terms and conditions of the GNU Lesser
+# General Public License v2.1. See the file LICENSE in the top level
+# directory for more details.
+
+import sys
+from testrunner import run
+from pexpect import TIMEOUT
+
+
+def testfunc(child):
+    res = child.expect([TIMEOUT, "FAILED ASSERTION."])
+    # we actually want the timeout here. The application runs into an assertion
+    # pretty quickly when failing and runs forever on success
+    assert(res == 0)

> In Python, `assert` is not considered as a function. That's my point. Which is not about style, but about correct the use of a programming language. Also I don't understand why you talk about `sizeof`. C is a different language, with different rules.

I won't further discuss this matter. This with as correct as without parenthesis. There is no harm and no repercussions (except a whiny `pylint`) with them.

> I guess you meant `assertEqual`.

No, I mean `assertRaises()`:

```diff
diff --git a/tests/thread_msg_block_race/tests/01-run.py b/tests/thread_msg_block_race/tests/01-run.py
index 7688bb862..cf9fef34d 100755
--- a/tests/thread_msg_block_race/tests/01-run.py
+++ b/tests/thread_msg_block_race/tests/01-run.py
@@ -7,15 +7,16 @@
 # directory for more details.
 
 import sys
-from testrunner import run
+from testrunner import PexpectTestCase
 from pexpect import TIMEOUT
 
 
-def testfunc(child):
-    res = child.expect([TIMEOUT, "FAILED ASSERTION."])
-    # we actually want the timeout here. The application runs into an assertion
-    # pretty quickly when failing and runs forever on success
-    assert(res == 0)
+class Test(PexpectTestCase):
+    def test_no_assertion(self):
+        with self.assertRaises(TIMEOUT):
+            # we actually want the timeout here. The application runs into an
+            # assertion pretty quickly when failing and runs forever on success
+            self.spawn.expect("FAILED ASSERTION.")
 
 
 if __name__ == "__main__":
```

BTW #10431 isn't merged yet because you are blocking it. Could you please revisit your comments there.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10908#discussion_r252966487
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190201/10fda2fc/attachment-0001.html>


More information about the notifications mailing list