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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:55:51+00:00 2026-05-21T09:55:51+00:00

I created a couple Middleware classes and want to test them against some real

  • 0

I created a couple Middleware classes and want to test them against some real views now. Since my app is not including any views or url conf itself I was wondering if there is a way to temporary create views and url configuration just for testing (similar to a test database) within Django’s test framework. In the end I would like to use the test client to check these temporary views against errors coming from the Middleware. I didn’t find some solution for this in the docs.

I know I could create a test view within my app (in views.py) and point from the projects ROOT_URLCONF to it, but I don’t want to force a user to do this when using my app and wanting to test my Middleware classes.

Any ideas?

Thanks.

  • 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-21T09:55:52+00:00Added an answer on May 21, 2026 at 9:55 am

    Yes this is possible if you are using the django.test.TestCase. Here are the docs on setting the url configuration for a specific test case: https://docs.djangoproject.com/en/1.8/topics/testing/tools/#urlconf-configuration

    When I have done this in the past I typically break up my test suite like a sub-app (without models):

    tests
        __init__.py
        urls.py
        views.py
        base.py
    

    Then in the test case you would set:

    class MiddlewareTestCase(TestCase):
        urls = 'appname.tests.urls'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created and edited a couple of tables and don't want to recreate them
Recently created a MVC2 Portal but now I want to add a couple of
I have created a couple of activities and stored them as XAML. Opening them
I recently created a couple inline table-valued UDF's and then referenced them in a
I've created a couple views showing e.g. the latest news and events. However, when
I am new in the Wpf world, so I created a couple of views
Since a couple of weeks, I've been using XCode 4.2 with projects created with
Though I have created couple of applications in Android , I have not much
I've already created a couple iPhone and iPad apps, but I've written them either
I have created a couple of different structures in a program. I now have

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.