File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed
Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -398,14 +398,14 @@ def temporary(
398398 """
399399 # Save current state
400400 saved = {
401- "unit" : self ._unit ,
402- "absolute" : self ._absolute ,
403- "relative" : self ._relative ,
404- "angular" : self ._angular ,
405- "approximation" : self ._approximation ,
406- "precision" : self ._precision ,
407- "lineardeflection" : self ._lineardeflection ,
408- "angulardeflection" : self ._angulardeflection ,
401+ "unit" : self .unit ,
402+ "absolute" : self .absolute ,
403+ "relative" : self .relative ,
404+ "angular" : self .angular ,
405+ "approximation" : self .approximation ,
406+ "precision" : self .precision ,
407+ "lineardeflection" : self .lineardeflection ,
408+ "angulardeflection" : self .angulardeflection ,
409409 }
410410 try :
411411 # Apply temporary changes
Original file line number Diff line number Diff line change @@ -62,6 +62,16 @@ def test_tolerance_temporary_restores_on_exception():
6262 assert TOL .absolute == original
6363
6464
65+ def test_tolerance_temporary_restores_unit ():
66+ """Test that temporary() restores values even if an exception occurs."""
67+ original = TOL .unit
68+
69+ with TOL .temporary (unit = "MM" ):
70+ assert TOL .unit == "MM"
71+
72+ assert TOL .unit == original
73+
74+
6575def test_tolerance_format_number ():
6676 assert TOL .format_number (0 , precision = 3 ) == "0.000"
6777 assert TOL .format_number (0.5 , precision = 3 ) == "0.500"
You can’t perform that action at this time.
0 commit comments