[Python-mode] run nose tests contained in the current emacs buffer

2011-07-28 Thread Tom Roche

I'd appreciate help fixing a problem running `nosetests` on the nose tests in a 
file within the current emacs buffer. I'm new to nose and fairly new to python, 
but have been coding awhile and using emacs forever, but don't know enough 
elisp to debug the code in question. I'm starting a nose tutorial

http://ivory.idyll.org/articles/nose-intro.html
> Here's the simplest nose test you can write:
>
> def test_b():
> assert 'b' == 'b'
>
> Put this in a file called test_me.py, and then run nosetests.

on an ubuntu box with python 2.6.5, GNU Emacs 23.1.50.1, and

me@it:~$ sudo easy_install nose
me@it:~$ pushd ~/code/python/nose/
me@it:~/code/python/nose$ ls -al
> -rw-r--r-- 1 me me   36 2011-07-28 18:47 test_me.py
me@it:~/code/python/nose$ nosetests -v
> test_stuff.test_b ... ok
>
> --
> Ran 1 test in 0.015s
>
> OK

But I wanna run from inside emacs, so I

1 downloaded nose.el from

https://bitbucket.org/jpellerin/nosemacs/src

2 hooked it into my init.el via

me@it:~/.emacs.d$ diff -u tlrPython.el~ tlrPython.el
...
> +;;; nose support (for testing)
> +(require 'nose)
> +(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 byte-compiled everything

4 restarted emacs

But when I open ~/code/python/nose/test_me.py in a buffer and do any of the key 
sequences

C-c m
C-c .
C-c a

I get buffer=*nosetests* like the following

> -*- mode: compilation; default-directory: "~/code/python/nose/" -*-
> Compilation started at Thu Jul 28 20:25:55
>
* nosetests -v   -w nil -c nilsetup.cfg /home/me/code/python/nose/test_me.py
> Traceback (most recent call last):
>   File "/usr/local/bin/nosetests", line 9, in 
> load_entry_point('nose==1.1.1', 'console_scripts', 'nosetests')()
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/core.py", 
> line 118, in __init__
> **extra_args)
>   File "/usr/lib/python2.6/unittest.py", line 816, in __init__
> self.parseArgs(argv)
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/core.py", 
> line 135, in parseArgs
> self.config.configure(argv, doc=self.usage())
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/config.py", 
> line 317, in configure
> self.configureWhere(options.where)
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/config.py", 
> line 400, in configureWhere
> "not a directory" % path)
> ValueError: Working directory nil not found, or not a directory
>
> Compilation exited abnormally with code 1 at Thu Jul 28 20:25:56

The only difference in the *nosetests* buffer is the `nosetests` line, which is 
variously

C-c m -> nosetests -v -w nil -c nilsetup.cfg 
/home/me/code/python/nose/test_me.py
C-c . -> nosetests -v -w nil -c nilsetup.cfg 
/home/me/code/python/nose/test_me.py:test_b
C-c a -> nosetests -v -w nil -c nilsetup.cfg

but I note, when running from bash, I get

me@it:~/code/python/nose$ nosetests -v   -w nil -c nilsetup.cfg 
/home/me/code/python/nose/test_me.py
... same error as above ...
me@it:~/code/python/nose$ nosetests -v   -w . -c nilsetup.cfg 
/home/me/code/python/nose/test_me.py
> Failure: ImportError (No module named test_me) ... ERROR
>
> ==
> ERROR: Failure: ImportError (No module named test_me)
> --
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/loader.py", 
> line 390, in loadTestsFromName
> addr.filename, addr.module)
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/importer.py",
>  line 39, in importFromPath
> return self.importFromDir(dir_path, fqname)
>   File 
> "/usr/local/lib/python2.6/dist-packages/nose-1.1.1-py2.6.egg/nose/importer.py",
>  line 71, in importFromDir
> fh, filename, desc = find_module(part, path)
> ImportError: No module named test_me
>
> --
> Ran 1 test in 0.005s
>
> FAILED (errors=1)
me@it:~/code/python/nose$ nosetests -v   -w . -c nilsetup.cfg test_me.py
> test_me.test_b ... ok
>
> --
> Ran 1 test in 0.004s
>
> OK
me@it:~/code/python/nose$ nosetests -v   -w . -c nilsetup.cfg ./test_me.py
> test_me.test_b ... ok
>
> --
> Ran 1 test in 0.006s
>
> OK
me@it:~/code/python/nose$ nosetests -v   -w . -c nilsetup.cfg 
./test_me.py:test_b
> test_me.t

[Python-mode] py-execute-buffer and swap buffers

2011-07-28 Thread Andrea Crotti

This is something I noticed since some time.
I have the latest bzr python-mode (but also before it was like this)
and emacs
GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.5)

When I have only two buffers open, one with the source and the other one 
with
the output, pressing C-c C-c (py-execute-buffer) swaps the two buffers 
every time,

which is extremely annoying...

Am I the only one seeing this?
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode


Re: [Python-mode] python-mode.el 6.0

2011-07-28 Thread Andreas Röhler

Am 28.07.2011 10:33, schrieb David Miller:

Nice work on this !

Just got around to upgrading to 6.0 and discovered that the python menu has
the option "Switch to interpreter" which maps to the function
py-switch-to-python



[ ... ]

Hi David,

it turned out having two labels pointing at the same, starting a 
py-shell resp. switching to basically.


Deleted the first.

As labeling might be a matter of taste just to mention it here.

Thanks again,

Andreas
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode


Re: [Python-mode] python-mode.el 6.0

2011-07-28 Thread Andreas Röhler

Am 28.07.2011 10:33, schrieb David Miller:

Nice work on this !

Just got around to upgrading to 6.0 and discovered that the python menu has
the option "Switch to interpreter" which maps to the function
py-switch-to-python

This function is undefined in the python-mode source AFAICT (e.g. based on
grepping the extracted tarfile)

Any ideas where the function comes from?



Hi,

thanks for the report. Made an entry in the bug tracker for the moment.
https://bugs.launchpad.net/python-mode/+bug/817389

If people could report bugs there, it's preferable to this list.

Best regards,

Andreas
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode


[Python-mode] python-mode.el 6.0

2011-07-28 Thread David Miller
Nice work on this !

Just got around to upgrading to 6.0 and discovered that the python menu has
the option "Switch to interpreter" which maps to the function
py-switch-to-python

This function is undefined in the python-mode source AFAICT (e.g. based on
grepping the extracted tarfile)

Any ideas where the function comes from?

2011/7/25 Barry Warsaw 

> On Jul 23, 2011, at 06:48 PM, Andreas Röhler wrote:
> >proudly announcing the release of
> >
> >python-mode.el 6.0 at
> >
> >http://launchpad.net/python-mode/trunk/6.0/+download/python-mode-6.0.tgz
>
> Congratulations Andreas!
>
> -Barry
>
> ___
> Python-mode mailing list
> Python-mode@python.org
> http://mail.python.org/mailman/listinfo/python-mode
>
>


-- 
Love regards etc

David Miller
http://www.deadpansincerity.com
07854 880 883
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode


[Python-mode] branch lp:~handrake/python-mode/devel-0.1

2011-07-28 Thread Andreas Röhler

Hi,

had a look at your branch this morning which looks quit reasonable for me.

When checking for a possible merge however detected, python-mode now 
don't make use of `py-shell-list' any more.


Which doesn't mean it can't be re-introduced if needed.

Could you check out the current trunk or release and tell if it fits 
your needs?


Thanks and best regards,

Andreas
___
Python-mode mailing list
Python-mode@python.org
http://mail.python.org/mailman/listinfo/python-mode