Open purplefishies opened 7 years ago
Hi,
I found an example online that solved my problem and allowed me to apply the "-m" filter more appropriately, but I wasn't able to find this documentation on the nosetests utility itself.
example
nosetests -v -m "_other" tests/*
test_other (tests.test_ethernet.TestEthernet) ... ok
test_other (tests.test_ethernet.TestEthernet) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.000s
OK
Perhaps just including an example that -m FILTER + tests/*.py would go a long way in the documentation to helping people understand how this filter can be applied.
Thanks
@purplefishies +1
I too have found the same problem, as documentation says files, directories, functions or classes
, when I give regex for directory
it's not obeying it... We need some examples to be included in documentation...
+1 here - fighting nosetests more than code at this stage :(
The tests/* did not work for me (issues with imports)
I'm using nosetests1.3.7 on Ubuntu 16.10
I have a simple directory structure as follows
controller/controller.py tests/test_ethernet.py
which looks like
class TestEthernet(unittest.TestCase):
If I run the default regular expression on the command line I see
So, I'm expecting logically , that if i run a regular expression that includes only the case insensitive version of "ethernet" in it that it would match. Nope
Example 1.
Your logic for how your -m regular expression is not obvious to the user.
Example 2.
However, I don't know what that last character is matching on. I've tried bisection and [e-s] is the only final character I can use to match the test cases. For instance,
But this regular expression has to match both "test_other" AND "test_ethernet". It seems like a very difficult regex writing system if you have to write a regex that matches ALL of the Files, the function and the class that you want to write. In addition, this requirement makes your documentation even harder to understand for this feature as it doesn't make logical sense compared to other test runner selection regular expression rules ( see Google Test and Ruby's unit test with -n option ) .
It might be easier to just concatenate the FN_NAME ( DIRECTORY:FILE:CLASS) and then apply the regular expression to that line created, for instance you could apply the regex to the line that is generated for --collect-only
ie.
nosetests -v -m "(?:^|[\b./-])[Tt]est" --collect-only test_other (tests.test_ethernet.TestEthernet) ... ok test_setup (tests.test_ethernet.TestEthernet) ... ok
Why not have the regular expression match on "test_setup (tests.test_ethernet.TestEthernet)"
so that -m ".ethernet." would match these two, ".setup.ethernet.*" would match only test_setup ...etc ?
I've got 20+ years of writing regular expressions and as it is the "-m" option is way too complicated because it is applied as a LOGICAL AND across The filename, Package, functioname and directories.
For instance according to the documentation "Files, directories, function names, and class names that match this regular expression are considered tests." . Hence
-m ".test_setup." matches one function name and should be included in the set of tests that would be run. It doesn't because the regex doesn't match the class that I want to use
No tests found
Google Test is an example of a much easier system for writing these regular expression filters for quicly selecting the test(s) you want to run after running --gtest_list_tests, followed by --gtest_filter="ethernet"