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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:52:08+00:00 2026-05-26T06:52:08+00:00

In my code, I’ve defined a class with its own repr method. The representation

  • 0

In my code, I’ve defined a class with its own repr method. The representation of the class should be a list.

def __repr__(self):
    if self.front <= self.tail:
        q = self._queue[self.front:self.tail+1]

    elif self.front > self.tail:
        q = self._queue[self.front:]
        q.extend(self._queue[:self.tail + 1])

    return (q.__repr__())

I’ve written the following unittest to test this method.

def test_enqueue(self):
    q = BoundedQueue(1)
    q.enqueue(1)
    self.assertEqual(q, [1])

However, I end up with an assertion error:

Traceback (most recent call last):
  File "test_internmatch_queue.py", line 13, in test_enqueue
    self.assertEqual(q, [1])
AssertionError: [1] != [1]

I’m not sure what the problem is… to my human eyes, [1]==[1]! I’ve tried several other variations in my repr method (below), and they all returned errors as well.

return repr(q)
return str(q)
  • 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-26T06:52:09+00:00Added an answer on May 26, 2026 at 6:52 am

    q is a BoundedQueue. [1] is a list. They can’t be equal unless you override __eq__. repr is not used for equality testing.

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

Sidebar

Related Questions

Code: for i in {0..3}; do ping http://www.pythonchallenge.com/pc/def/$i.html; done A host should be found
(code examples are python) Lets assume we have a list of percentages that add
Code below defines a ChargeCustomer class that contains an array of type customers. I
code: http://jsfiddle.net/WRppV/4/ I should get something like content=> [141, [203, 206, 204, 205], 142,
code: public class Main{ public static void main(String[] a){ long t=24*1000*3600; System.out.println(t*25); System.out.println(24*1000*3600*25); }
Code-behind: public partial class WebForm1 : System.Web.UI.Page { protected override void OnInit(EventArgs e) {
code structure @protocal A_Delegate { -(void)doIt:(BOOL)isDone; } Super Class A // has properties of
CODE:1 class Ajay { private void display() { System.out.println(Ajay); } public static void main(String
Code can be found here: http://www.myhorizon.ca/client_central/sortable_test.php Hello folks of Stackoverflow, I have a list
Code: public interface IFoo { void Bar(); } public class FooClass : IFoo {

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.