Nose can't find tests in ubuntu

Is there a reason Nose won't be able to find tests in Ubuntu 9.04?

I am using nose 0.11.1 with python 2.5.4.
I can run tests only if I explicitly specify the file name. If I do not provide a file name, it simply says: 0 tests .

The same project works fine on my Mac, so I'm completely offline!

+46
python nose
Sep 21 '09 at 21:55
source share
7 answers

Something related if you run tests from the ie directory

nosetests ... tests/ 

where tests is the name of the folder with my tests and have separate python testing functions in one of the .py modules ... Your functions should start with a "test" so that the nosychists know that you want to run as a test.

eg:

  def test_something(): ... 

nosetests will run this function when executed in this directory, and

  def somethin_to_test(): ... 

will not be.

+6
Sep 17 '13 at 21:55
source share

Another thing that always gets me with nose is that it will not run tests in executable files. I'm not quite sure why this will affect Mac / Ubuntu, but it's worth it.

Make sure that the scripts somehow did not get chmod +x 'd on the Mac ... And if they did, fix them with chmod -x $(find tests/ -name '*.py') .

+92
Oct. 16 '09 at 18:57
source share

This behavior is almost certainly due to the fact that your files are not listed in accordance with the nose matching behavior. From nasal documents :

the nose automatically collects tests from the source files, directories, and python packages found in its working directory (which by default refers to the current working directory). Any source file, directory, or python package that matches the testMatch regular expression (default: (?: ^ | [B _.-]) [Tt] est) will be compiled as a test (or source for collecting tests).

The emphasis was mine.

Some names of examples that will match:

  • Testfoo.py
  • Foo-Test.py
  • Foo_Test.py
  • Foo.Test.py (note that this one will try to import Foo and will throw an exception if it cannot)

A name that looks like a match, but not really:

  • FooTest.py

If you just rename your files, you should be good to go.




Refresh . Have you read this blog post ? I couldn’t tell you about the details that you posted, but maybe your __init__.py files are missing in your test directories?

... make sure your "test" directories are actually modules (they have an empty __init__.py file).

+54
Sep 22 '09 at 2:24
source share

I had the same problem. My tests went fine on Windows, but not on Ubuntu.

In Ubuntu, if you run:

 nosetests -vv --collect-only 

You will probably see that it skips your test file because it is executable: _Tools / LintControlFiles / test_HgLint.py is executable; skipped

To get a nose for reviewing executable files, run it as follows:

 nosetests --exe 
+34
Sep 14 2018-11-11T00:
source share

I can confirm that, as @ david-wolever said, they cannot be executable on Ubuntu. Run

 nosetests -vv --collect-only 

to view complete information about which files were viewed.

+16
Apr 13 '11 at 5:22
source share

After looking at the source of the nose, in particular the selector.py file, if you look at what’s happening,

https://github.com/nose-devs/nose/blob/master/nose/selector.py#L129

When checking, if we wantFile , wantFile is self.matches , which then does a regex lookup against the match that you would pass as testMatch .

The problem occurs when you then check later (and, in this file),

https://github.com/nose-devs/nose/blob/master/nose/selector.py#L152

The same type of checks is wantFunction .

This means that if you have a different structure for your package, your pyfile and your actual test class / function, you need to create a crazy complex regular expression to match this at every step.

For me, when I found out about this, I decided to prefix my packages, containers and test functions with a common bit, i.e.

setests β”œβ”€β”€ __init__.py β”œβ”€β”€ setest_area1.py └──── def setest_someblock(): ...

And then my nose team works like,

nose --testMatch="setest"

Then it filters, as I expect it to work.

+1
Jan 12 '17 at 19:51 on
source share

Use -all-modules and it will find all the tests.

nosetests --all-modules ./tests

0
Dec 20 '17 at 15:15
source share



All Articles