summaryrefslogtreecommitdiff
path: root/test/examples_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/examples_test.py')
-rw-r--r--test/examples_test.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/examples_test.py b/test/examples_test.py
new file mode 100644
index 0000000..f5fe924
--- /dev/null
+++ b/test/examples_test.py
@@ -0,0 +1,29 @@
+'''test by running example scripts
+'''
+from __future__ import division # new in 2.2, redundant in 3.0
+from __future__ import absolute_import # new in 2.5, redundant in 2.7/3.0
+from __future__ import print_function # new in 2.6, redundant in 3.0
+
+import os
+import os.path
+import subprocess
+
+#import py.test as test
+
+
+def test_examples():
+ '''run non-gui example scripts and check they exit successfully.
+ '''
+ os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples'))
+ for f in (x for x in os.listdir('.') if x.endswith('.py')):
+ retcode = subprocess.call('python %s' % f, shell=True)
+ assert retcode == 0, 'Error: {0} retcode == {1}'.format(f, retcode)
+
+
+def test_snippets_png():
+ '''run all snippets in png mode and check they exit successfully.
+ '''
+ os.chdir(os.path.join(os.path.dirname(__file__), '..', 'examples',
+ 'cairo_snippets'))
+ retcode = subprocess.call('python snippets_png.py -s', shell=True)
+ assert retcode == 0, 'Error: retcode == {0}'.format(retcode)