Skip to content

Commit e1bee2c

Browse files
committed
use ExitStack to reset Settings after test
1 parent f348d63 commit e1bee2c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

test/test_asian.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from quantlib.quotes import SimpleQuote
2323
from quantlib.termstructures.volatility.api import BlackConstantVol
2424

25+
import contextlib
2526
import unittest
2627

2728
from .utilities import flat_rate
@@ -42,9 +43,11 @@ class AsianOptionTestCase(unittest.TestCase):
4243
"""
4344

4445
def setUp(self):
45-
4646
self.settings = Settings()
47-
47+
stack = contextlib.ExitStack()
48+
self.settings = stack.enter_context(Settings())
49+
self.addCleanup(stack.close)
50+
4851
self.calendar = NullCalendar()
4952

5053
self.today = Date(6, June, 2021)
@@ -96,10 +99,9 @@ def setUp(self):
9699

97100
self.payoff = PlainVanillaPayoff(self.option_type, self.strike)
98101

99-
100102
def test_analytic_cont_geom_av_price(self):
101103
"""
102-
"Testing analytic continuous geometric average-price Asians...")
104+
Testing analytic continuous geometric average-price Asians
103105
104106
data from "Option Pricing Formulas", Haug, pag.96-97
105107
"""

0 commit comments

Comments
 (0)