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

Included contexts: wrong ordering and duplicates of before/after blocks #130

Closed
m-kostrzewa opened this issue Feb 15, 2019 · 3 comments · Fixed by #131
Closed

Included contexts: wrong ordering and duplicates of before/after blocks #130

m-kostrzewa opened this issue Feb 15, 2019 · 3 comments · Fixed by #131
Milestone

Comments

@m-kostrzewa
Copy link
Contributor

m-kostrzewa commented Feb 15, 2019

I think there are two issues:

  • ordering of teardown steps seem to be the other way around
  • -all blocks of the outermost context get called twice for some reason

Example 1: just -each

from mamba import description, context, it, before, after, shared_context, included_context

with shared_context("A"):
    with before.each:
        print("A.BEFORE")
    with after.each:
        print("A.AFTER")


with shared_context("B"):
    with before.each:
        print("B.BEFORE")
    with after.each:
        print("B.AFTER")

with description("Example") as self:
    with included_context("A"):
        with included_context("B"):
            with it("IT"):
                print("IT")

Expected:

A.BEFORE
B.BEFORE
IT
B.AFTER
A.AFTER

Actual:

A.BEFORE
B.BEFORE
IT
A.AFTER
B.AFTER

Example 2: just -all

from mamba import description, context, it, before, after, shared_context, included_context

with shared_context("A"):
    with before.all:
        print("A.BEFORE")
    with after.all:
        print("A.AFTER")


with shared_context("B"):
    with before.all:
        print("B.BEFORE")
    with after.all:
        print("B.AFTER")

with description("Data extraction") as self:
    with included_context("A"):
        with included_context("B"):
            with it("IT"):
                print("IT")

Expected:

A.BEFORE
B.BEFORE
IT
B.AFTER
A.AFTER

Actual:

A.BEFORE
A.BEFORE
B.BEFORE
IT
A.AFTER
B.AFTER
A.AFTER

Example 3: -each and -all

from mamba import description, context, it, before, after, shared_context, included_context

with shared_context("A"):
    with before.each:
        print("A.BEFORE.EACH")
    with after.each:
        print("A.AFTER.EACH")
    with before.all:
        print("A.BEFORE.ALL")
    with after.all:
        print("A.AFTER.ALL")


with shared_context("B"):
    with before.each:
        print("B.BEFORE.EACH")
    with after.each:
        print("B.AFTER.EACH")
    with before.all:
        print("B.BEFORE.ALL")
    with after.all:
        print("B.AFTER.ALL")

with description("Data extraction") as self:
    with included_context("A"):
        with included_context("B"):
            with it("IT"):
                print("IT")

Expected:

A.BEFORE.ALL
B.BEFORE.ALL
A.BEFORE.EACH
B.BEFORE.EACH
IT
B.AFTER.EACH
A.AFTER.EACH
B.AFTER.ALL
A.AFTER.ALL

Actual:

A.BEFORE.ALL
A.BEFORE.ALL
B.BEFORE.ALL
A.BEFORE.EACH
B.BEFORE.EACH
IT
A.AFTER.EACH
B.AFTER.EACH
A.AFTER.ALL
B.AFTER.ALL
A.AFTER.ALL
@m-kostrzewa
Copy link
Contributor Author

Actually, even for normal context, the ordering is wrong:

from mamba import description, context, it, before, after, shared_context, included_context

with description("Data extraction") as self:
    with context("A"):
        with before.each:
            print("A.BEFORE")
        with after.each:
            print("A.AFTER")
        with context("B"):
            with before.each:
                print("B.BEFORE")
            with after.each:
                print("B.AFTER")
            with it("IT"):
                print("IT")

Results are same as for included contexts in this case

@m-kostrzewa
Copy link
Contributor Author

I'm using v0.10 from pip, but I saw some fixes on master branch, gonna try it

@m-kostrzewa
Copy link
Contributor Author

^ My mistake, the fixes were from January, but a year ago... so no fix.

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 a pull request may close this issue.

2 participants