Comments (4)
DDT creates four tests out of one, as you can see in output these are named:
test_larger_than_two_12
test_larger_than_two_23
test_larger_than_two_3
test_larger_than_two_4
So test_larger_than_two
is no longer an individual test (that was kind of the whole point of ddt
).
From what I've gathered, there is no way to issue a nosetests
command-line that would run these four tests (e.g. by matching function name with a regex).
That said, you should be able to run them individually:
nosetests -vv test_foo.py:FooTestCase.test_larger_than_two_4
But nose still fails with:
$ nosetests -v test/test_example.py:FooTestCase.test_larger_than_two_4
Failure: ValueError (no such test method in <class 'test.test_example.FooTestCase'>: test_larger_than_two) ... ERROR
======================================================================
ERROR: Failure: ValueError (no such test method in <class 'test.test_example.FooTestCase'>: test_larger_than_two)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/carles/.virtualenvs/ddt/local/lib/python2.7/site-packages/nose/loader.py", line 518, in makeTest
return self._makeTest(obj, parent)
File "/home/carles/.virtualenvs/ddt/local/lib/python2.7/site-packages/nose/loader.py", line 572, in _makeTest
return parent(obj.__name__)
File "/usr/lib/python2.7/unittest/case.py", line 191, in __init__
(self.__class__, methodName))
ValueError: no such test method in <class 'test.test_example.FooTestCase'>: test_larger_than_two
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
So it may be something related with how nose loads/runs the tests when running an individual method. I'll try to debug and see if something can be done within ddt
.
from ddt.
Thank you @txels for the explanation (totally makes sense to me). Since I usually generate random data for my tests, it would be impossible to know ahead of time what the test name would be. I really appreciate anything you can do to help :)
from ddt.
I've been able to fix this. Turns out there was a mismatch between the new function as attribute in the test class and the function name of said function. Released as 0.7.1
Now I can do:
$ nosetests -s -v test/test_example.py:FooTestCase.test_larger_than_two_3
test_larger_than_two_3 (test.test_example.FooTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Or even:
$ nosetests -s -v 'test/test_example.py:FooTestCase.test_tuples_extracted_into_arguments_(3, 2)'
test_tuples_extracted_into_arguments_(3, 2) (test.test_example.FooTestCase) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.000s
But unfortunately nosetests
doesn't allow me to select all functions matching a name... (something like FooTestCase.test_larger_than_two*
). Will have to submit a patch to nose for that ;)
from ddt.
Though this won't help me with my scenario (where @DaTa uses random values every time), I'm glad you fixed the other use case :) Cheers!
from ddt.
Related Issues (20)
- Add @named_data to give tests meaningful names. HOT 1
- Consider dropping support for all EOL versions Python 2.7 - 3.6 HOT 1
- How to import `named_data`? HOT 1
- Allow `named_data` to take tuples (any `collections.Sequence`)
- Async tests no longer work on python 3.11
- sdist is missing `tox.ini` HOT 6
- 1.7.0: `flake8` reports `pycodestyle` errors HOT 5
- 1.7.0: Has Python 2.7 classifiers but is Python 3+ only. HOT 2
- ddt interaction with setUp and tearDown HOT 2
- Django runserver finds that @file_data has loaded the data and cannot be changed[Help me] HOT 1
- Test Case Ordinal Numbering zero-pads poorly HOT 1
- Index only test names HOT 1
- New release causes error on import HOT 4
- 1.4.1: test suite is failing HOT 2
- Cleanup
- Docs → Example Usage: contents of example data files not shown? HOT 1
- (DDT+Excel+Unittest)How to control the execution of each test case HOT 2
- Test failure with PyYAML 5.4.1 HOT 4
- Signature change of `ddt.idata` in 1.4.3 breaks downstream uses
- @ifile_data - an iterable @file_data decorator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ddt.