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

The Archive Base Latest Questions

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

When I run a unit-test where I am testing for equality of two integers,

  • 0

When I run a unit-test where I am testing for equality of two integers, I get an assertion error exception instead of unittest reporting a failure, then proceding to the next test. Here is the test code (greatly simplified to prove the point).

import unittest

class TestClass(unittest.TestCase):

    def test_method(self):
        myVariable = 1
        self.assertTrue(myVariable==0)

if __name__ == '__main__':
    unittest.main()

The traceback is as follows:

builtins.AssertionError: False is not true
File "C:\Dev\Volleyball\test.py", line 10, in <module>
  unittest.main()
File "C:\Program Files\python32\Lib\unittest\main.py", line 124, in __init__
  self.runTests()
File "C:\Program Files\python32\Lib\unittest\main.py", line 270, in runTests
  self.result = testRunner.run(self.test)
File "C:\Program Files\python32\Lib\unittest\runner.py", line 168, in run
  test(result)
File "C:\Program Files\python32\Lib\unittest\suite.py", line 67, in __call__
  return self.run(*args, **kwds)
File "C:\Program Files\python32\Lib\unittest\suite.py", line 105, in run
  test(result)
File "C:\Program Files\python32\Lib\unittest\suite.py", line 67, in __call__
  return self.run(*args, **kwds)
File "C:\Program Files\python32\Lib\unittest\suite.py", line 105, in run
  test(result)
File "C:\Program Files\python32\Lib\unittest\case.py", line 498, in __call__
  return self.run(*args, **kwds)
File "C:\Program Files\python32\Lib\unittest\case.py", line 446, in run
  self._executeTestPart(testMethod, outcome, isTest=True)
File "C:\Program Files\python32\Lib\unittest\case.py", line 391, in _executeTestPart
  function()
File "C:\Dev\Volleyball\test.py", line 7, in test_method
  self.assertTrue(myVariable==0)
File "C:\Program Files\python32\Lib\unittest\case.py", line 527, in assertTrue
  raise self.failureException(msg)

Am I doing something wrong, or am I misunderstanding how test assertions work?

For the record, I am using Python 3.2.1 on Windows 7.

TIA, Alan

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

    Right – thanks to @agf I have reached an acceptable compromise. I have removed AssertionError from the ‘Always Report’ section of the ‘Debugger:Exceptions’ and now the debugger no longer stops on the assertion. The downside is that while this is fine while running a test script (because I will see the results in the failure list), when running the ‘real’ program I will have to keep an eye on the ‘Debug I/O’
    output to view assertions.

    Thanks to all who replied.

    Alan

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

Sidebar

Related Questions

I am getting the error below when I run a unit test: completed successfully
If I open a solution in Visual Studio 2008 and run a unit test
I need to use the ReSharper Unit Test Runner to run my MSTest Unit
I have a unit test where I run a method for every item in
Is it possible to write and run with Visual Studio 2008 some unit test
Is there a way, within IDLE, to run the PyUnit (unittest module) unit tests
I would like to accomplish two things during my build process: Run unit tests
I'd like to run a unit test where a constant is slightly different than
Should unit testing be run in debug or release mode? I am using Visual
Possible Duplicate: How should I unit test threaded code? The classical unit testing is

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.