Update copyright years again.
[org-mode.git] / testing / lisp / test-ob-python.el
bloba3cae8c01c20c412ac3d6b57aad1cf20cb1b0c04
1 ;;; test-ob-python.el --- tests for ob-python.el
3 ;; Copyright (c) 2011-2014 Eric Schulte
4 ;; Authors: Eric Schulte
6 ;; This file is not part of GNU Emacs.
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Code:
22 (org-test-for-executable "python")
23 (unless (featurep 'ob-python)
24 (signal 'missing-test-dependency "Support for Python code blocks"))
26 (ert-deftest test-ob-python/colnames-yes-header-argument ()
27 (org-test-with-temp-text "#+name: eg
28 | col |
29 |-----|
30 | a |
31 | b |
33 #+header: :colnames yes
34 #+header: :var x = eg
35 #+begin_src python
36 return x
37 #+end_src"
38 (org-babel-next-src-block)
39 (should (equal '(("col") hline ("a") ("b"))
40 (org-babel-execute-src-block)))))
42 (ert-deftest test-ob-python/colnames-yes-header-argument-again ()
43 (org-test-with-temp-text "#+tblname: less-cols
44 | a |
45 |---|
46 | b |
47 | c |
49 #+header: :colnames yes
50 #+begin_src python :var tab=less-cols
51 return [[val + '*' for val in row] for row in tab]
52 #+end_src"
53 (org-babel-next-src-block)
54 (should (equal '(("a") hline ("b*") ("c*"))
55 (org-babel-execute-src-block)))))
57 (ert-deftest test-ob-python/colnames-nil-header-argument ()
58 (org-test-with-temp-text "#+name: eg
59 | col |
60 |-----|
61 | a |
62 | b |
64 #+header: :colnames nil
65 #+header: :var x = eg
66 #+begin_src python
67 return x
68 #+end_src"
69 (org-babel-next-src-block)
70 (should (equal '(("col") hline ("a") ("b"))
71 (org-babel-execute-src-block)))))
73 (ert-deftest test-ob-python/colnames-no-header-argument-again ()
74 (org-test-with-temp-text "#+tblname: less-cols
75 | a |
76 |---|
77 | b |
78 | c |
80 #+header: :colnames no
81 #+begin_src python :var tab=less-cols
82 return [[val + '*' for val in row] for row in tab]
83 #+end_src"
84 (org-babel-next-src-block)
85 (should (equal '(("a*") ("b*") ("c*"))
86 (org-babel-execute-src-block)))))
88 (ert-deftest test-ob-python/colnames-no-header-argument ()
89 (org-test-with-temp-text "#+name: eg
90 | col |
91 |-----|
92 | a |
93 | b |
95 #+header: :colnames no
96 #+header: :var x = eg
97 #+begin_src python
98 return x
99 #+end_src"
100 (org-babel-next-src-block)
101 (should (equal '(("col") ("a") ("b"))
102 (org-babel-execute-src-block)))))
104 (provide 'test-ob-python)
106 ;;; test-ob-python.el ends here