Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:54:20+00:00 2026-06-04T14:54:20+00:00

Deo python support setUp() and tearDown() acts differently depending on the context? By all

  • 0

Deo python support setUp() and tearDown() acts differently depending on the context? By all means, I am asking about if I can do something like this:

setUp() {
    if(context1){
         do A;
    }
    else{
         do B;
    }
}


tearDown() {
    if(context1){
         do A;
    }
    else{
         do B;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:54:21+00:00Added an answer on June 4, 2026 at 2:54 pm

    Yeah, and just like you show it: use if blocks and only do particular parts of the setup if the condition is true.

    I think what you’re getting at is to have different versions of setUp and tearDown for different tests. I’d actually suggest that you either:

    • split the tests into different TestCase subclasses with the proper setUp/tearDown methods
    • or don’t use setUp and tearDown at all – do something like this

      class MyTestCase:
          def _setup_for_foo_tests():
              # blah blah blah
          def _setup_for_bar_tests():
              # blah blah blah
          def test_foo_1():
              self._setup_for_foo_tests()
              # test code
          def test_foo_2():
              self._setup_for_foo_tests()
              # test code
          def test_bar_1():
              self._setup_for_bar_tests()
              # test code
          # etc etc etc
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i want to deo something like this and not sure how for($s=0; $s
I am trying to make a simple call to the pow() function from math.h
My boss was messing around with this page and suddenly it stopped working and
a friend of mine declared a new type using typedef GLfloat vec3_t[3]; and later
I get this error when I load my video show view: SyntaxError in Videos#show
After finishing two cs classes, I've started working on a personal project in Java.
i am trying my hand at using the crystal space api in my graphics
I am using Devise in an app for the first time and I am
Here's what I am looking to create. The dollar amounts are linked to a
I noticed a very funny error message Facebook API returns when I tried to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.