File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,7 @@ def copy(self):
98
98
TestgresConfig = testgres_config
99
99
100
100
# stack of GlobalConfigs
101
- config_stack = [testgres_config ]
101
+ config_stack = []
102
102
103
103
104
104
def rm_cached_initdb_dirs ():
@@ -123,7 +123,7 @@ def pop_config():
123
123
Set previous GlobalConfig options from stack.
124
124
"""
125
125
126
- if len (config_stack ) <= 1 :
126
+ if len (config_stack ) == 0 :
127
127
raise IndexError ('Reached initial config' )
128
128
129
129
# restore popped config
@@ -141,9 +141,10 @@ def scoped_config(**options):
141
141
... print(node.execute('select 1'))
142
142
"""
143
143
144
- # set a new config with options
145
- config = push_config (** options )
146
144
try :
145
+ # set a new config with options
146
+ config = push_config (** options )
147
+
147
148
# return it
148
149
yield config
149
150
finally :
Original file line number Diff line number Diff line change @@ -549,7 +549,16 @@ def test_config_stack(self):
549
549
self .assertEqual (c1 .cached_initdb_dir , d1 )
550
550
551
551
with scoped_config (cached_initdb_dir = d2 ) as c2 :
552
+
553
+ stack_size = len (testgres .config .config_stack )
554
+
555
+ # try to break a stack
556
+ with self .assertRaises (TypeError ):
557
+ with scoped_config (dummy = True ):
558
+ pass
559
+
552
560
self .assertEqual (c2 .cached_initdb_dir , d2 )
561
+ self .assertEqual (len (testgres .config .config_stack ), stack_size )
553
562
554
563
self .assertEqual (c1 .cached_initdb_dir , d1 )
555
564
You can’t perform that action at this time.
0 commit comments