Giter Club home page Giter Club logo

Comments (4)

txels avatar txels commented on August 24, 2024

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.

omaciel avatar omaciel commented on August 24, 2024

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.

txels avatar txels commented on August 24, 2024

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.

omaciel avatar omaciel commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.