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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:27:10+00:00 2026-06-17T13:27:10+00:00

All my unit tests succeed running in Python 2.6.5; one fails when I run

  • 0

All my unit tests succeed running in Python 2.6.5; one fails when I run through Python 2.7.3. The code being tested is complex and involves lots of working in floats and converting to Decimal along the way, by converting to str first as was needed in Python 2.6.

Before I start digging, I was wondering if I could be a bit lazy and see if someone has seen this before and has suggestions on what to search for. Here’s the result of the test run:

======================================================================
FAIL: test_hor_tpost_winsize_inside_mm (__main__.Test_ShutterCalculator)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_ShutterCalculator.py", line 506, in test_hor_tpost_winsize_inside_mm
    self.assertEqual(o.net_width_closing_tolerance, Decimal("6.4"))
AssertionError: Decimal('6.3') != Decimal('6.4')

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

Here’s the unit test code for test_hor_tpost_winsize_inside_mm():

490     def test_hor_tpost_winsize_inside_mm(self):
491         """
492         Same as above but test mm
493         """
494         o = self.opening
495         o.unit_of_measure = "millimeters"
496         o.formula_mode = "winsize"
497         o.mount = "inside"
498         o.given_width = Decimal("1117.6")
499         o.given_height = Decimal("2365.4")
500         o.louver_spacing = Decimal("101.6")
501         self.make4SidedFrame("9613", '9613: 2-1/2" Face Deco Z', Decimal("63.5"), Decimal("19.1"))
502         so1 = o.subopenings[(0,0)]
503         so1.fold_left = 1
504         so1.fold_right = 1
505         self.calc()
506         self.assertEqual(o.net_width_closing_tolerance, Decimal("6.4"))
507         self.assertEqual(o.net_height_closing_tolerance, Decimal("6.4"))
508         self.assertEqual(o.horizontal_shim, Decimal(".125"))  # in inches
509         self.assertEqual(o.vertical_shim, Decimal(".125"))  # in inches
510         self.assertEqual(o.width, Decimal("1069.8"))  ## 1070 converted directly from inches
511         self.assertEqual(o.height, Decimal("2317.6")) ## 2317.8 converted directy from inches
512         tpost = o.add_hor_tpost()
513         so2 = o.subopenings[(0,1)]
514         so2.fold_left = 1
515         so2.fold_right = 1
516         self.calc()
517         #self.cs()
518         self.assertEqual(o.net_width_closing_tolerance, Decimal("6.4"))
519         self.assertEqual(o.net_height_closing_tolerance, Decimal("12.7"))
520         self.assertEqual(o.horizontal_shim, Decimal(".125"))  # in inches
521         self.assertEqual(o.vertical_shim, Decimal(".125"))  # in inches
522         self.assertEqual(o.width, Decimal("1069.8"))  ## Rick had 42 but agreed that mine is right
523         self.assertEqual(o.height, Decimal("2311.3"))
524         self.assertEqual(so1.width, Decimal("1069.8"))
525         self.assertEqual(so2.width, Decimal("1069.8"))
526         self.assertEqual(so1.height, Decimal("1139.7"))  ## Rick had 44.8125 but agreed mine is right
527         self.assertEqual(so2.height, Decimal("1139.7"))
528         self.assertEqual(tpost.center_pos, Decimal("1182.7"))
529         top_panel_section = so1.panels[0].sections[(0,0)]
530         bottom_panel_section = so2.panels[0].sections[(0,0)]
531         self.assertEqual(top_panel_section.louver_count, 9)
532         self.assertEqual(bottom_panel_section.louver_count, 9)
533         self.assertEqual(top_panel_section.top_rail.width, Decimal("112.6"))  ## Rick had 4.40625, but given the changes to net
534         self.assertEqual(bottom_panel_section.bottom_rail.width, Decimal("112.7"))
535         self.assertEqual(top_panel_section.bottom_rail.width, Decimal("112.7"))
536         self.assertEqual(bottom_panel_section.top_rail.width, Decimal("112.6"))

Any hint on what to search for in my code to find the source of the discrepancy?

  • 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-17T13:27:12+00:00Added an answer on June 17, 2026 at 1:27 pm

    Python 2.7 introduced changes to the Decimal class and float type to help improve accuracy when converting from strings. This could be the source of the change.

    Conversions between floating-point numbers and strings are now correctly rounded on most platforms. These conversions occur in many different places: str() on floats and complex numbers; the float and complex constructors; numeric formatting; serializing and deserializing floats and complex numbers using the marshal, pickle and json modules; parsing of float and imaginary literals in Python code; and Decimal-to-float conversion.

    You can see the change details here, under “Other language changes”

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

Sidebar

Related Questions

my continuous integration server (TeamCity) is configured to run all the unit tests in
Is it possible to enable Resharper to automatically run all unit tests within a
Using Visual Studio 2010, is there a way to run all unit tests in
I'm using Python's unittest library and all the tests succeed, but I still get
I would like to migrate all my unit tests from NUnit to MSTest. In
My project has some unit tests. They all depend on some external service, over
I'm trying to write a unit test that will loop through all action methods
All, I'm trying to do some unit testing in some archaic java code (no
We have a (very) multithreaded application that would pass all unit tests, but would
From reasons I won't get into, all our unit tests are using the VSTS

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.