Issue #2 new

adding ".py" to nose-project-root-files fails to find tests in current buffer

Tom Roche
created an issue

{{{

!email

http://lists.idyll.org/pipermail/testing-in-python/2011-July/004284.html

nosetests -v -w nil -c nilsetup.cfg /home/me/code/python/nose/test_me.py

http://lists.idyll.org/pipermail/testing-in-python/2011-July/004287.html

The '-w nil' is the problem -- nose.el is unable to find your project's root directory. }}} Correct. Note that was with an untouched nose.el OOTB from bitbucket.

{{{

!email

By default [nose.el] looks for the root directory by backing up from the file it is given, looking for any of 'setup.py', '.hg' or '.git'. You can modify the files it looks for by modifying nose-project-root-files }}} That fails for me; more below.

{{{

!email

or change the way it tests for rootness of a directory by setting nose-project-root-test. }}} Didn't try that.

{{{

!email

Or just touch setup.py in your project root. }}} That works. Here's my experience:

0 Note my top-level setup (e.g., ubuntu, emacs, nose.el, python) is the same as given in previous issue https://bitbucket.org/jpellerin/nosemacs/issue/1/cant-run-nose-tests-contained-in-the

1.0 I tried touch setup.py: {{{

!init.el contains

(load "tlrPython") }}} {{{

!tlrPython.el contains

;;; nose support (for testing): see ;;; .../site-lisp/python/nose.el ;;; from ;;; https://bitbucket.org/jpellerin/nosemacs/src/0192bf439dc9/nose.el (require 'nose) ;;; default keybindings from nose.el (add-hook 'python-mode-hook (lambda () (local-set-key "\C-ca" 'nosetests-all) (local-set-key "\C-cm" 'nosetests-module) (local-set-key "\C-c." 'nosetests-one) (local-set-key "\C-cpa" 'nosetests-pdb-all) (local-set-key "\C-cpm" 'nosetests-pdb-module) (local-set-key "\C-cp." 'nosetests-pdb-one))) }}} {{{

!nose.el contains (unchanged from bitbucket)

(defvar nose-project-names '("eco/bin/test")) (defvar nose-project-root-files '("setup.py" ".hg" ".git")) (defvar nose-project-root-test 'nose-project-root) }}} {{{

!$HOME/code/python/nose/ contains (from http://ivory.idyll.org/articles/nose-intro.html)

-rw-r--r-- 1 tlroche tlroche 0 2011-07-29 13:13 setup.py -rw-r--r-- 1 tlroche tlroche 70 2011-07-29 13:12 testExampleTwo.py -rw-r--r-- 1 tlroche tlroche 70 2011-07-28 22:07 testExampleTwo.py~ -rw-r--r-- 1 tlroche tlroche 530 2011-07-29 13:19 testExampleTwo.pyc -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 20:28 test_me.py -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 18:47 test_me.py~ -rw-r--r-- 1 tlroche tlroche 307 2011-07-28 20:35 test_me.pyc }}}

1.1 results: success: from buffer=testExampleTwo.py, given key sequences produce given results {{{

!english

C-c . (on second line) -> nosetests -v -w /home/tlroche/code/python/nose/ -c /home/tlroche/code/python/nose/setup.cfg /home/tlroche/code/python/nose/testExampleTwo.py:TestExampleTwo.test_c C-c m -> nosetests -v -w /home/tlroche/code/python/nose/ -c /home/tlroche/code/python/nose/setup.cfg /home/tlroche/code/python/nose/testExampleTwo.py C-c a -> nosetests -v -w /home/tlroche/code/python/nose/ -c /home/tlroche/code/python/nose/setup.cfg }}}

2.0 I tried modifying nose-project-root-files from my config file: {{{

!init.el unchanged

(load "tlrPython") }}} {{{

!tlrPython.el changed, then byte-compiled, then emacs restarted

;;; nose support (for testing): see ;;; .../site-lisp/python/nose.el ;;; from ;;; https://bitbucket.org/jpellerin/nosemacs/src/0192bf439dc9/nose.el (require 'nose) (add-to-list 'nose-project-root-files ".py") ;;; default keybindings from nose.el (add-hook 'python-mode-hook (lambda () (local-set-key "\C-ca" 'nosetests-all) (local-set-key "\C-cm" 'nosetests-module) (local-set-key "\C-c." 'nosetests-one) (local-set-key "\C-cpa" 'nosetests-pdb-all) (local-set-key "\C-cpm" 'nosetests-pdb-module) (local-set-key "\C-cp." 'nosetests-pdb-one))) }}} {{{

!nose.el contains (unchanged from bitbucket)

(defvar nose-project-names '("eco/bin/test")) (defvar nose-project-root-files '("setup.py" ".hg" ".git")) (defvar nose-project-root-test 'nose-project-root) }}} {{{

!$HOME/code/python/nose/ no longer contains setup.py

-rw-r--r-- 1 tlroche tlroche 70 2011-07-29 13:12 testExampleTwo.py -rw-r--r-- 1 tlroche tlroche 70 2011-07-28 22:07 testExampleTwo.py~ -rw-r--r-- 1 tlroche tlroche 530 2011-07-29 13:19 testExampleTwo.pyc -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 20:28 test_me.py -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 18:47 test_me.py~ -rw-r--r-- 1 tlroche tlroche 307 2011-07-28 20:35 test_me.pyc }}}

2.1 results: failure: from buffer=testExampleTwo.py, given key sequences produce given results {{{

!english

C-c . (on second line) -> nosetests -v -w nil -c nilsetup.cfg /home/tlroche/code/python/nose/testExampleTwo.py:TestExampleTwo.test_c C-c m -> nosetests -v -w nil -c nilsetup.cfg /home/tlroche/code/python/nose/testExampleTwo.py C-c a -> nosetests -v -w nil -c nilsetup.cfg }}}

3.0 I tried modifying nose-project-root-files in nose.el: {{{

!init.el unchanged

(load "tlrPython") }}} {{{

!nose.el changed, then byte-compiled

(defvar nose-project-names '("eco/bin/test")) (defvar nose-project-root-files '(".py" ".hg" ".git")) (defvar nose-project-root-test 'nose-project-root) }}} {{{

!$HOME/code/python/nose/ remains setup.py-less

-rw-r--r-- 1 tlroche tlroche 70 2011-07-29 13:12 testExampleTwo.py -rw-r--r-- 1 tlroche tlroche 70 2011-07-28 22:07 testExampleTwo.py~ -rw-r--r-- 1 tlroche tlroche 530 2011-07-29 13:19 testExampleTwo.pyc -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 20:28 test_me.py -rw-r--r-- 1 tlroche tlroche 36 2011-07-28 18:47 test_me.py~ -rw-r--r-- 1 tlroche tlroche 307 2011-07-28 20:35 test_me.pyc }}} {{{

!tlrPython.el changed, then byte-compiled, then emacs restarted

;;; nose support (for testing): see ;;; .../site-lisp/python/nose.el ;;; from ;;; https://bitbucket.org/jpellerin/nosemacs/src/0192bf439dc9/nose.el (require 'nose) ;(add-to-list 'nose-project-root-files ".py") ;;; default keybindings from nose.el (add-hook 'python-mode-hook (lambda () (local-set-key "\C-ca" 'nosetests-all) (local-set-key "\C-cm" 'nosetests-module) (local-set-key "\C-c." 'nosetests-one) (local-set-key "\C-cpa" 'nosetests-pdb-all) (local-set-key "\C-cpm" 'nosetests-pdb-module) (local-set-key "\C-cp." 'nosetests-pdb-one))) }}}

3.1 results: failure: from buffer=testExampleTwo.py, given key sequences produce given results {{{

!english

C-c . (on second line) -> nosetests -v -w nil -c nilsetup.cfg /home/tlroche/code/python/nose/testExampleTwo.py:TestExampleTwo.test_c C-c m -> nosetests -v -w nil -c nilsetup.cfg /home/tlroche/code/python/nose/testExampleTwo.py C-c a -> nosetests -v -w nil -c nilsetup.cfg }}}

I claim this is a bug, because touch setup.py alone produces the desired behavior modifying nose-project-root-files "the right way" (i.e., from my config file, leaving nose.el untouched) fails * ... and even modifying nose-project-root-files "the wrong way" (i.e., in nose.el) fails Am I missing something?

Comments (1)

  1. Jason Pellerin repo owner

    nose-project-root-files are literal filenames, not globs, so adding '.py' won't work unless there is a file literally named '.py' in your project root.

  2. Log in to comment