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 8355459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:52:06+00:00 2026-06-09T09:52:06+00:00

I would like to execute test suite with Selenium RC in Python. In this

  • 0

I would like to execute test suite with Selenium RC in Python. In this set of tests I would like to:

  1. With help of Selenium simulate user input data on website
  2. Check if data are correctly put into database
  3. Get an email from selected account and parse it to check if data is correct

All tests are in principle finished, but they do not work as entire test suite containing those three tests. I tried to generate data in setUp method, but in all tests the data was different. I already learned that in every test execution setUp() and tearDown() methods are run so I tried to move my data generators into test class constructor, but I still can’t deal with it.

Structure of my test looks as follows:

class TestClass(unittest.TestCase):
  def __init__(self, TestClass):
     unittest.TestCase.__init__(self, TestClass)
     self.define_random_data()
  def setUp(self):
    db_connection_function(self)
  def some_internal_methods(self):
    ...
  def test_website_data_input(self):
    ...
  def test_db_test(self):
    ...
  def test_email_parse(self):
    ...
  def tearDown(self):
    ...
suite = unittest.TestLoader().loadTestsFromTestCase(TestClass)
unittest.TextTestRunner(verbosity=2).run(suite)

What am I doing wrong? In every test generated data is different and I do not know how to deal with it – I tried to run this method in every possible place, but it is still wrong.

  • 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-09T09:52:07+00:00Added an answer on June 9, 2026 at 9:52 am

    Ah okay. A new instance of the TestClass is created for each test method that is run. So you would have to do this.

    import unittest
    import random
    random_data = random.random()
    
    class TestClass(unittest.TestCase):
        def __init__(self, TestClass):
            unittest.TestCase.__init__(self, 'test_first')
            self.data = random_data
    
        def test_first(self):
            self.fail(self.data)
    
        def test_second(self):
            self.fail(self.data)
    
    if __name__ == '__main__':
        unittest.main()
    

    I’ve just tested that and prints out the same failure message for each test. The random data is only generated on the import of the test module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like an automated web tests suite based on Selenium RC to take
I would like to execute code sequentially in an NSOperation. This can be easily
I would like to execute some program through ssh and redirect its input from
I have a specific DB2 query, and I would like to execute this query
I'm working with the Struts2 framework and would like to unit test the execute
I would like to execute Selenesse test written in FItNesse when I launch maven
I would like to execute an Ajax request every seconds. My next code work
I would like to execute a MySQL command in a shell script/cron job that
I would like to execute some kind of subquery with my fetchedresultscontroller. I've got
I would like to execute a procedure periodically, how to do that in MySQL?

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.