File tree Expand file tree Collapse file tree 1 file changed +10
-6
lines changed
Orange/widgets/data/tests Expand file tree Collapse file tree 1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change 11import unittest
22from unittest import mock
3+ from contextlib import ExitStack
34
45import os
56import io
1112
1213from AnyQt .QtCore import QSettings
1314
15+ from Orange .tests import named_file
1416from Orange .widgets .tests .base import WidgetTest , GuiTest
1517from Orange .widgets .data import owcsvimport
1618from Orange .widgets .data .owcsvimport import (
2123
2224class TestOWCSVFileImport (WidgetTest ):
2325 def setUp (self ):
24- # patch `_local_settings` to avoid side effects
25- s = QSettings (os .devnull , QSettings .IniFormat )
26- self ._patch = mock .patch .object (
27- owcsvimport .OWCSVFileImport , "_local_settings" , lambda * a : s )
28- self ._patch .__enter__ ()
26+ self ._stack = ExitStack ().__enter__ ()
27+ # patch `_local_settings` to avoid side effects, across tests
28+ fname = self ._stack .enter_context (named_file ("" ))
29+ s = QSettings (fname , QSettings .IniFormat )
30+ self ._stack .enter_context (mock .patch .object (
31+ owcsvimport .OWCSVFileImport , "_local_settings" , lambda * a : s
32+ ))
2933 self .widget = self .create_widget (owcsvimport .OWCSVFileImport )
3034
3135 def tearDown (self ):
3236 self .widgets .remove (self .widget )
3337 self .widget .onDeleteWidget ()
3438 self .widget = None
35- self ._patch . __exit__ ()
39+ self ._stack . close ()
3640
3741 def test_basic (self ):
3842 w = self .widget
You can’t perform that action at this time.
0 commit comments