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

there is no suite setup execute info in the log #169

Open
jackwucn opened this issue Jan 18, 2024 · 7 comments
Open

there is no suite setup execute info in the log #169

jackwucn opened this issue Jan 18, 2024 · 7 comments

Comments

@jackwucn
Copy link

image

only display the test setup log. but there is no suite setup info . I am sure the suite or session setup is exetuted.

@DetachHead
Copy link
Owner

hmm, i thought pytest didn't really have a concept of suite-level setup and teardown, only fixtures that get called by individual tests as they're needed. but reading into it more i see it supports setup_module and teardown_module functions. i could probably hook those to make them show in the log as suite-level setup/teardowns.

could you please confirm that's how you're defining your suite setup? or are there other ways to do it?

@jackwucn
Copy link
Author

jackwucn commented Jan 18, 2024

image
only this function has been logged

@DetachHead
Copy link
Owner

ok so there's a few reasons for this:

  • the logs from your listener don't work because robot itself doesn't support logging outside of a test from a listener
  • the pytest_sessionstart one doesn't get logged because that hook is called at the very beginning of the pytest session before any tests are collected and before robot starts, which means it's impossible for robot to know about it
  • the session-scoped fixtures are lazily executed (ie. only executed when a test needs them). for example, the following test suite will execute the functions in the following order: test_foo, setup, then test_bar:
    @fixture(scope="session")
    def setup():
        info("1") # runs second
    
    
    def test_foo():
        info("2") # runs first
    
    
    def test_bar(setup: None):
        info("3") # runs last

i'm going to make some changes that should make setup_module and teardown_module show up as suite setups in the log, so i would recommend doing it that way

@DetachHead
Copy link
Owner

actually, even setup_module and teardown_module only get executed in the setup/teardown stage of an individual test (the first or last one in a suite), so i think think supporting it would be difficult, and it would also cause issues if i add support for xdist in the future (#98), since the contents of the "setup" keyword would appear to be duplicated if a suite is split across multiple runners.

i'll keep this issue open for now but i'm not sure if it's feasible

@jackwucn
Copy link
Author

when I use setup_module, it has been executed before each test case, My hopes is it execute only once before the module.
image

@fixture(scope="session")
def setup():
logging.info("1")
the fixture did't execute. when I and autouse=True, It also executed before each test case.

@DetachHead
Copy link
Owner

what version of the plugin are you using? i suspect that's the same issue as #161 which was fixed in the latest version (2.5.1)

@jackwucn
Copy link
Author

jackwucn commented Jan 19, 2024

it's working now, after upgrade to 2.5.1.
Thanks for you kindly reply

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

No branches or pull requests

2 participants