test-ob-python.el 2.1 KB

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