git » libfiu » commit 7ad3ac4

tests: Add a few basic tests

author Alberto Bertogli
2014-05-25 13:42:33 UTC
committer Alberto Bertogli
2014-05-25 23:45:15 UTC
parent 8b7b0b3234c86e0653d54ca2bcbecd1579a1b2c9

tests: Add a few basic tests

Looking at the test coverage, there were a few simple things that the existing
tests were not covering; this patch fixes some of those by adding a couple of
basic but useful tests.

tests/test-basic.py +30 -0
tests/test-wildcards.py +2 -0

diff --git a/tests/test-basic.py b/tests/test-basic.py
new file mode 100644
index 0000000..8a9f0d7
--- /dev/null
+++ b/tests/test-basic.py
@@ -0,0 +1,30 @@
+"""
+Basic tests for general functionality.
+"""
+
+import fiu
+
+# Test unknown failure point.
+assert not fiu.fail('unknown')
+
+# Test enable/disable.
+fiu.enable('p1')
+assert fiu.fail('p1')
+fiu.disable('p1')
+assert not fiu.fail('p1')
+
+# Test enable_random.
+fiu.enable_random('p1', probability = 0.5)
+result = { True: 0, False: 0 }
+for i in range(1000):
+    result[fiu.fail('p1')] += 1
+
+assert 400 < result[True] < 600, result
+assert 400 < result[False] < 600, result
+
+# Test repeated enabling/disabling.
+fiu.enable('p1')
+fiu.enable('p1')
+assert fiu.fail('p1')
+fiu.disable('p1')
+assert not fiu.fail('p1')
diff --git a/tests/test-wildcards.py b/tests/test-wildcards.py
index 6603299..abfcd7d 100644
--- a/tests/test-wildcards.py
+++ b/tests/test-wildcards.py
@@ -12,6 +12,8 @@ assert fiu.fail("a:b:c")
 assert fiu.fail("a:b:x")
 assert fiu.fail("a:b:c:d")
 
+fiu.enable("a:b:*")  # Test repeated enabling of a wildcard.
+
 fiu.enable("a:b:c:d")
 assert fiu.fail("a:b:c:d")