summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Chaplin <stevech1097@yahoo.com.au>2009-08-04 17:58:01 +0800
committerSteve Chaplin <stevech1097@yahoo.com.au>2009-08-04 17:58:01 +0800
commit3fa2fdcc8fb14070d5a7a4e6dd7c59b8e7ade91b (patch)
treeb2fea52345bc5199317d40b6e9bb1fed1b33466b
parent32c50c81e328b4e24b13b2c7eb0aac6715511c34 (diff)
downloadpy2cairo-3fa2fdcc8fb14070d5a7a4e6dd7c59b8e7ade91b.tar.gz
Add new test files
-rw-r--r--test/api_test.py54
-rw-r--r--test/examples_test.py29
2 files changed, 83 insertions, 0 deletions
diff --git a/test/api_test.py b/test/api_test.py
new file mode 100644
index 0000000..6a8db8c
--- /dev/null
+++ b/test/api_test.py
@@ -0,0 +1,54 @@
+'''test pycairo API
+- can be expanded later as required.
+- is not able to test the quality of images created. We assume cairo itself
+ tests for this.
+'''
+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 tempfile as tfi
+
+import cairo
+import py.test as test
+
+
+def test_context():
+ pass
+
+def test_matrix():
+ pass
+
+def test_path():
+ pass
+
+def test_patterns():
+ pass
+
+
+def test_surfaces():
+ # The Surface type cannot be instantiated
+ test.raises(TypeError, "s = cairo.Surface()")
+
+ if cairo.HAS_IMAGE_SURFACE:
+ f, w, h = cairo.FORMAT_ARGB32, 100, 100
+ s = cairo.ImageSurface(f, w, h)
+ assert s.get_format() == f
+ assert s.get_width() == w
+ assert s.get_height() == h
+
+ if cairo.HAS_PDF_SURFACE:
+ f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
+ s = cairo.PDFSurface(f, w, h)
+
+ if cairo.HAS_PS_SURFACE:
+ f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
+ s = cairo.PSSurface(f, w, h)
+
+ if cairo.HAS_SVG_SURFACE:
+ f, w, h = tfi.TemporaryFile(mode='w+b'), 100, 100
+ s = cairo.SVGSurface(f, w, h)
+
+
+def test_text():
+ pass
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)