alfredodeza / pytest.vim

Runs your UnitTests with py.test displaying red/green bars and errors
274 stars 40 forks source link

:Pytest method not working #54

Closed jaesbit closed 6 years ago

jaesbit commented 6 years ago

On every try to execute :Pytest method get Unable to find a matching method for testing

alfredodeza commented 6 years ago

This is because the call is "context aware". It depends on the position of your cursor searching backwards. In this case it should work:

class TestFoo(object):

    def test_foo(self):
        assert True
    <cursor position here>

But this would not work:

class TestFoo(object):

<cursor position here>

    def test_foo(self):
        assert True
alfredodeza commented 6 years ago

If that is not the case, then could you show me some examples of the code you are trying to test and where your cursor is at the moment of invocation?

jaesbit commented 6 years ago

I'm using pytest, and not defining class like with unit test, maybe is for that, I attach you a test file test_files.txt

alfredodeza commented 6 years ago

@atgiovannini you are using a function, not a class, so you would need to do:

:Pytest function 

Alternatively, to run the whole file:

:Pytest file
jaesbit commented 6 years ago

Yeah, I'm using :Pytest file now, and I'm sorry, I didn't read about :Pytest function in README. Then, can close issue ;)