alfredodeza / pytest.vim

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

Cannot run test classes with inner classes #24

Closed sloria closed 9 years ago

sloria commented 9 years ago

Test classes with inner classes fail to run.

The following code reproduces the problem:

class TestFoo:
    class MyClass:
        pass

    def test_method_with_inner_class(self):
        obj = self.MyClass()
        assert isinstance(obj, object)

Running either Pytest class or Pytest method results in an error:

ERROR: not found: /Users/sloria/tmp/scratch-1421564807/t.py::MyClass
(no name '/Users/sloria/tmp/scratch-1421564807/t.py::MyClass' in any of [<Module 't.py'>])

I am using the latest version of pytest.vim and pytest 2.6.3.

alfredodeza commented 9 years ago

@sloria mind checking out the issue24 branch and see if that fixes your problem? I tried and it works for me.

sloria commented 9 years ago

@alfredodeza Running Pytest class now works correctly, but Pytest method seems to have been broken. Here is the test class I was using: https://github.com/marshmallow-code/marshmallow/blob/7826ae0d4813772dd79a876e99cf816cb2b22642/tests/test_schema.py#L1935-2033

alfredodeza commented 9 years ago

@sloria sorry about that, mind trying it again? I think this is good to go now.

sloria commented 9 years ago

@alfredodeza Yep, seems to be working. Thanks!

alfredodeza commented 9 years ago

Fixed with https://github.com/alfredodeza/pytest.vim/pull/25

dbedrenko commented 8 years ago

FYI, in case @alfredodeza ever has a regression with this issue or something similar, using nested classes in py.test is not supported. Here is a line from a chat I had with one of the devs:

2014 Feb 26 14:03:41 SpaghettiCat_: dont use nested classes, they dont propagate data propperly - and its not supported