Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed testSetups/testTeardowns not being run for parent layers in Such #211

Merged
merged 1 commit into from
Jul 3, 2014

Conversation

aloysbaillet
Copy link
Contributor

It took a little while, but I think this is right...
Fixes #127

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) when pulling 7ba2d3f on aloysbaillet:fix_issue_127 into d886f92 on nose-devs:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling 7ba2d3f on aloysbaillet:fix_issue_127 into d886f92 on nose-devs:master.

@thedrow
Copy link
Member

thedrow commented Jul 1, 2014

What about class setUp and tearDown?

@aloysbaillet
Copy link
Contributor Author

This test "higher_layer_setup.py" is checking the behaviour of setUp, which is only called once per layer. I assumed this was correct.

@thedrow
Copy link
Member

thedrow commented Jul 2, 2014

Nope. Both test_setup and setup should be called once for each layer.

@aloysbaillet
Copy link
Contributor Author

OK, but then what's the difference between test_setup and setup?

On Wed, Jul 2, 2014 at 4:28 PM, Omer Katz notifications@github.com wrote:

Nope. Both test_setup and setup should be called once for each layer.


Reply to this email directly or view it on GitHub
#211 (comment).

Aloys Baillet
LEGO Movie Craftman

@thedrow
Copy link
Member

thedrow commented Jul 2, 2014

setup runs once for each layer. test_setup runs once for each test.

@aloysbaillet
Copy link
Contributor Author

To eliminate any doubt, could you update this code to show exactly what you expect to happen?

import logging
log = logging.getLogger(__name__)

from nose2.tools import such

with such.A('foo') as it:
    it.upper_run = 0
    it.lower_run = 0

    @it.has_setup
    def upper_test_setup(case):
        log.error('foo::setUp')
        it.upper_run += 1

    with it.having('some bar'):
        @it.has_setup
        def lower_test_setup(case):
            log.error('foo some bar::setUp')
            it.lower_run += 1

        @it.should("run all setups")
        def test_run_all_setups(case):
            case.assertEquals(it.upper_run, 1)
            case.assertEquals(it.lower_run, 1)

        @it.should("run all setups just once")
        def test_run_all_setups_just_once(case):
            case.assertEquals(it.upper_run, 1)
            case.assertEquals(it.lower_run, 1)

it.createTests(globals())

@thedrow
Copy link
Member

thedrow commented Jul 2, 2014

That's exactly what should happen.

@aloysbaillet
Copy link
Contributor Author

Good news: that's one of the new tests in the PR:-)
On 02/07/2014 10:14 pm, "Omer Katz" notifications@github.com wrote:

That's exactly what should happen.


Reply to this email directly or view it on GitHub
#211 (comment).

@thedrow
Copy link
Member

thedrow commented Jul 2, 2014

So this is mergeable? :)

@aloysbaillet
Copy link
Contributor Author

Good question :-) I would think so, as it doesn't break anything and adds a
few more Such tests...

On Thu, Jul 3, 2014 at 9:05 AM, Omer Katz notifications@github.com wrote:

So this is mergeable? :)


Reply to this email directly or view it on GitHub
#211 (comment).

Aloys Baillet
LEGO Movie Craftman

thedrow added a commit that referenced this pull request Jul 3, 2014
Fixed testSetups/testTeardowns not being run for parent layers in Such
@thedrow thedrow merged commit b276fb4 into nose-devs:master Jul 3, 2014
@aloysbaillet aloysbaillet deleted the fix_issue_127 branch July 3, 2014 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The Layers plugin doesn't run a Such testSetUp of the higher layer
3 participants