Skip to content

Commit

Permalink
Merge pull request #428 from whirm/add_trial_test_runner
Browse files Browse the repository at this point in the history
Add support for Twisted's Trial test runner.
  • Loading branch information
jorgenschaefer committed Jan 9, 2015
2 parents eab67e7 + 10d576f commit d447513
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
17 changes: 16 additions & 1 deletion elpy.el
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ message again within this amount of seconds."
:type '(choice (const :tag "Unittest Discover" elpy-test-discover-runner)
(const :tag "Django Discover" elpy-test-django-runner)
(const :tag "Nose" elpy-test-nose-runner)
(const :tag "py.test" elpy-test-pytest-runner))
(const :tag "py.test" elpy-test-pytest-runner)
(const :tag "Twisted Trial" elpy-test-trial-runner))
:safe 'elpy-test-runner-p
:group 'elpy)

Expand Down Expand Up @@ -1874,6 +1875,20 @@ This requires the nose package to be installed."
"nosetests")))
(put 'elpy-test-nose-runner 'elpy-test-runner-p t)

(defun elpy-test-trial-runner (top file module test)
"Test the project using Twisted's Trial test runner.
This requires the twisted-core package to be installed."
(interactive (elpy-test-at-point))
(if module
(elpy-test-run top
"trial" (if test
(format "%s.%s" module test)
module))
(elpy-test-run top
"trial")))
(put 'elpy-test-trial-runner 'elpy-test-runner-p t)

(defun elpy-test-pytest-runner (top file module test)
"Test the project using the py.test test runner.
Expand Down
63 changes: 63 additions & 0 deletions test/elpy-test-trial-runner-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(ert-deftest elpy-test-trial-runner-should-be-test-runner ()
(elpy-testcase ()
(elpy-test-runner-p 'elpy-test-trial-runner)))

(ert-deftest elpy-test-trial-runner-should-run-all-tests ()
(elpy-testcase ()
(mletf* ((command nil)
(top nil)
(elpy-test-run (start-dir &rest args) (setq command args
top start-dir)))

(elpy-test-trial-runner "/project/root/" nil nil nil)

(should (equal command '("trial")))
(should (equal top "/project/root/")))))

(ert-deftest elpy-test-trial-runner-should-run-test-module ()
(elpy-testcase ()
(mletf* ((command nil)
(top nil)
(elpy-test-run (start-dir &rest args) (setq command args
top start-dir)))

(elpy-test-trial-runner "/project/root/"
"/project/root/package/module.py"
"package.module"
nil)

(should (equal command
'("trial" "package.module")))
(should (equal top "/project/root/")))))

(ert-deftest elpy-test-trial-runner-should-run-test-class ()
(elpy-testcase ()
(mletf* ((command nil)
(top nil)
(elpy-test-run (start-dir &rest args) (setq command args
top start-dir)))

(elpy-test-trial-runner "/project/root/"
"/project/root/package/module.py"
"package.module"
"TestClass")

(should (equal command
'("trial" "package.module.TestClass")))
(should (equal top "/project/root/")))))

(ert-deftest elpy-test-trial-runner-should-run-test-method ()
(elpy-testcase ()
(mletf* ((command nil)
(top nil)
(elpy-test-run (start-dir &rest args) (setq command args
top start-dir)))

(elpy-test-trial-runner "/project/root/"
"/project/root/package/module.py"
"package.module"
"TestClass.test_method")

(should (equal command
'("trial" "package.module.TestClass.test_method")))
(should (equal top "/project/root/")))))

0 comments on commit d447513

Please sign in to comment.