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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:23:23+00:00 2026-05-15T21:23:23+00:00

I am trying to test for an exception. I have: def test_set_catch_status_exception(self): mro =

  • 0

I am trying to test for an exception.

I have:

def test_set_catch_status_exception(self):
    mro = self.mro
    NEW_STATUS = 'No such status'
    self.assertRaises(ValueError,mro.setStatus(NEW_STATUS))

I get the following error:

======================================================================
ERROR: test_set_catch_status_exception (__main__.TestManagementReviewGoalGetters)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_ManagementReviewObjective.py", line 68, in test_set_catch_status_exception
    self.assertRaises(ValueError,mro.setStatus(NEW_STATUS))
  File "/Users/eric/Dropbox/ManagementReview.py", line 277, in setStatus
    raise ValueError('%s is not in the list of allowed statuses: %s' % (status,LIST_OF_STATUSES))
ValueError: No such status is not in the list of allowed statuses: ['Concern or Delay', 'On Track', 'Off Track/Needs Attention']

----------------------------------------------------------------------

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-15T21:23:23+00:00Added an answer on May 15, 2026 at 9:23 pm

    self.assertRaises expects a function mro.setStatus, followed by an arbitrary number of arguments: in this case, just NEW_STATUS. self.assertRaises assembles its arguments into the function call mro.setStatus(NEW_STATUS) inside a try...except block, thus catching and recording the ValueError if it occurs.

    Passing mro.setStatus(NEW_STATUS) as an argument to self.assertRaises causes the ValueError to occur before self.assertRaises can trap it.

    So the fix is to change the parentheses to a comma:

    self.assertRaises(ValueError,mro.setStatus,NEW_STATUS)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to test that a particular method throws an expected exception from
I'm trying to test that I'm throwing an exception when appropriate. In my test
I have written a bunch of entities. I am trying to test them now.
I am trying to unit test my sqlalchemy code. def add_user(*user_details): try: u =
I have a spring mvc project and am trying to test out a rest
I am trying to test an ANTLR grammar with such a standard test rig
I am trying to test UDP communications on a LAN. I have a small
I have a web service I am trying to unit test. In the service
I am trying the MVC3 exception handling, and came with following test code: public
I have been trying for several hours now to get sorl-thumbnail working, but it

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.