Skip to content

How to pass a variable from a test to another test #3403

Closed
@aMillionTears

Description

@aMillionTears

I write a test class, it has two test methods. What I want to do is, at the first test I'd like to get some result and assign to a variable; and at the second test I want to do some test depend on this variable. What's the best way to do this? Currently, I use a "global", and I know I can put these two tests into a same method. But I look forward a better solution.

Thanks for submitting an issue!

Here's a quick checklist in what to include:

  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • pytest and operating system versions
  • Minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions