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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:20:58+00:00 2026-06-13T10:20:58+00:00

During a unittest I would like to compare a generated URL with a static

  • 0

During a unittest I would like to compare a generated URL with a static one defined in the test. For this comparison it would be good to have a TestCase.assertURLEqual or similar which would let you compare two URLs in string format and result in True if all query and fragment components were present and equal but not necessarily in order.

Before I go implement this myself, is this feature around already?

  • 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-13T10:20:59+00:00Added an answer on June 13, 2026 at 10:20 am

    I don’t know if there is something built-in, but you could simply use urlparse and check yourself for the query parameters since order is taken into account by default.

    >>> import urlparse
    >>> url1 = 'http://google.com/?a=1&b=2'
    >>> url2 = 'http://google.com/?b=2&a=1'
    >>> # parse url ignoring query params order
    ... def parse_url(url):
    ...   u = urlparse.urlparse(url)
    ...   q = u.query
    ...   u = urlparse.urlparse(u.geturl().replace(q, ''))
    ...   return (u, urlparse.parse_qs(q))
    ... 
    >>> parse_url(url1)
    (ParseResult(scheme='http', netloc='google.com', path='/', params='', query='', fragment=''), {'a': ['1'], 'b': ['2']})
    >>> def assert_url_equals(url1, url2):
    ...   return parse_url(url1) == parse_url(url1)
    ...
    >>> assert_url_equals(url1, url2)
    True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During the process of building software applications, you would start testing what you have
I have an ant task set up like so: <target name=unit-test description=unit tests depends=compile-tests>
I'm trying to get my head around how one would unit test an ASP.NET
I would like to test my library in an android application, but I would
Duplicate question of this . I have a class like this: template <class T>
During Session Start, one has access to the Request object. How about Session End,
I am currently experimenting with TFS, and I really like it. One small question,
I have been perpetually intrigued by test-driven development, but I can never follow through
I have some test case classes organized in directories foo_tests foo_tests1.py foo_tests2.py ... bar_tests
I have unit test, i use guice for di, i annotate my class with

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.