Manually revert to the Release 7.8.04 tag.
[org-mode.git] / testing / lisp / test-ob-python.el
blobd6a41333321a5f289eebb555352492a1d4992b79
1 ;;; test-ob-python.el --- tests for ob-python.el
3 ;; Copyright (c) 2011-2012 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; Released under the GNU General Public License version 3
7 ;; see: http://www.gnu.org/licenses/gpl-3.0.html
9 ;;; Code:
10 (org-test-for-executable "python")
11 (unless (featurep 'ob-python)
12 (signal 'missing-test-dependency "Support for Python code blocks"))
14 (ert-deftest test-ob-python/colnames-yes-header-argument ()
15 (org-test-with-temp-text "#+name: eg
16 | col |
17 |-----|
18 | a |
19 | b |
21 #+header: :colnames yes
22 #+header: :var x = eg
23 #+begin_src python
24 return x
25 #+end_src"
26 (org-babel-next-src-block)
27 (should (equal '(("col") hline ("a") ("b"))
28 (org-babel-execute-src-block)))))
30 (ert-deftest test-ob-python/colnames-yes-header-argument-again ()
31 (org-test-with-temp-text "#+tblname: less-cols
32 | a |
33 |---|
34 | b |
35 | c |
37 #+header: :colnames yes
38 #+begin_src python :var tab=less-cols
39 return [[val + '*' for val in row] for row in tab]
40 #+end_src"
41 (org-babel-next-src-block)
42 (should (equal '(("a") hline ("b*") ("c*"))
43 (org-babel-execute-src-block)))))
45 (ert-deftest test-ob-python/colnames-nil-header-argument ()
46 (org-test-with-temp-text "#+name: eg
47 | col |
48 |-----|
49 | a |
50 | b |
52 #+header: :colnames nil
53 #+header: :var x = eg
54 #+begin_src python
55 return x
56 #+end_src"
57 (org-babel-next-src-block)
58 (should (equal '(("col") hline ("a") ("b"))
59 (org-babel-execute-src-block)))))
61 (ert-deftest test-ob-python/colnames-no-header-argument-again ()
62 (org-test-with-temp-text "#+tblname: less-cols
63 | a |
64 |---|
65 | b |
66 | c |
68 #+header: :colnames no
69 #+begin_src python :var tab=less-cols
70 return [[val + '*' for val in row] for row in tab]
71 #+end_src"
72 (org-babel-next-src-block)
73 (should (equal '(("a*") ("b*") ("c*"))
74 (org-babel-execute-src-block)))))
76 (ert-deftest test-ob-python/colnames-no-header-argument ()
77 (org-test-with-temp-text "#+name: eg
78 | col |
79 |-----|
80 | a |
81 | b |
83 #+header: :colnames no
84 #+header: :var x = eg
85 #+begin_src python
86 return x
87 #+end_src"
88 (org-babel-next-src-block)
89 (should (equal '(("col") ("a") ("b"))
90 (org-babel-execute-src-block)))))
92 (provide 'test-ob-python)
94 ;;; test-ob-python.el ends here