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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:52:42+00:00 2026-05-27T04:52:42+00:00

Given that webtest doesn’t seem to have a 3.x version (or any plans to

  • 0

Given that webtest doesn’t seem to have a 3.x version (or any plans to develop one), are there any solutions for automated system testing of a WSGI application? I know unittest for unit testing – I’m more interested in the moment in whole systems tests.

I’m not looking for tools to help develop an application – just test it.

  • 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-05-27T04:52:43+00:00Added an answer on May 27, 2026 at 4:52 am

    In case anyone else comes upon this, I ended up writing a solution myself.
    Here’s a very simple class I use – I just inherit from WSGIBaseTest instead of TestCase, and get a method self.request() that I can pass requests into.
    It stores cookies, and will automatically send them into the application on later requests (until self.new_session() is called).

    import unittest
    from wsgiref import util
    import io
    
    class WSGIBaseTest(unittest.TestCase):
        '''Base class for unit-tests. Provides up a simple interface to make requests
        as though they came through a wsgi interface from a user.'''
        def setUp(self):
            '''Set up a fresh testing environment before each test.'''
            self.cookies = []
        def request(self, application, url, post_data = None):
            '''Hand a request to the application as if sent by a client.
            @param application: The callable wsgi application to test.
            @param url: The URL to make the request against.
            @param post_data: A string.'''
            self.response_started = False
            temp = io.StringIO(post)
            environ = {
                'PATH_INFO': url,
                'REQUEST_METHOD': 'POST' if post_data else 'GET',
                'CONTENT_LENGTH': len(post),
                'wsgi.input': temp,
                }
            util.setup_testing_defaults(environ)
            if self.cookies:
                environ['HTTP_COOKIE'] = ';'.join(self.cookies)
            self.response = ''
            for ret in application(environ, self._start_response):
                assert self.response_started
                self.response += str(ret)
            temp.close()
            return response
        def _start_response(self, status, headers):
            '''A callback passed into the application, to simulate a wsgi
            environment.
    
            @param status: The response status of the application ("200", "404", etc)
            @param headers: Any headers to begin the response with.
            '''
            assert not self.response_started
            self.response_started = True
            self.status = status
            self.headers = headers
            for header in headers:
                # Parse out any cookies and save them to send with later requests.
                if header[0] == 'Set-Cookie':
                    var = header[1].split(';', 1)
                    if len(var) > 1 and var[1][0:9] == ' Max-Age=':
                        if int(var[1][9:]) > 0:
                            # An approximation, since our cookies never expire unless
                            # explicitly deleted (by setting Max-Age=0).
                            self.cookies.append(var[0])
                        else:
                            index = self.cookies.index(var[0])
                            self.cookies.pop(index)
        def new_session(self):
            '''Start a new session (or pretend to be a different user) by deleting
            all current cookies.'''
            self.cookies = []
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that one can define a class in VB Script, is there any way
Given that I only have one monitor, what's the best way to debug a
Given that I have an IEnumerable<T> , where T is any object, how can
Given that Subversion has basically been written to replace CVS, are there any compelling
Given that there are many sizes and color depths for different phones (even for
given that I have a vector: x <- c(m1, m2, m3) and every element
Given that I have a pointer to a function (provided by dlsym() for example)
Given that the following snippet doesn't compile: std::stringstream ss; ss << std::wstring(Labc); I didn't
Given that I have the appropriate rights, how can I get performance data (ie.
Given that Jabaco is VB-alike on the surface but Java underneath, can any suggest

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.