Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dd8c500

Browse files
committed
more tests for config stack
1 parent 72976a6 commit dd8c500

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

tests/test_simple.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
TimeoutException
2424

2525
from testgres import \
26-
scoped_config
26+
TestgresConfig, \
27+
configure_testgres, \
28+
scoped_config, \
29+
pop_config
2730

2831
from testgres import \
2932
NodeStatus, \
@@ -529,6 +532,29 @@ def test_pg_config(self):
529532
b = get_pg_config()
530533
self.assertNotEqual(id(a), id(b))
531534

535+
def test_config_stack(self):
536+
# no such option
537+
with self.assertRaises(TypeError):
538+
configure_testgres(dummy=True)
539+
540+
# we have only 1 config in stack
541+
with self.assertRaises(IndexError):
542+
pop_config()
543+
544+
d0 = TestgresConfig.cached_initdb_dir
545+
d1 = 'dummy_abc'
546+
d2 = 'dummy_def'
547+
548+
with scoped_config(cached_initdb_dir=d1) as c1:
549+
self.assertEqual(c1.cached_initdb_dir, d1)
550+
551+
with scoped_config(cached_initdb_dir=d2) as c2:
552+
self.assertEqual(c2.cached_initdb_dir, d2)
553+
554+
self.assertEqual(c1.cached_initdb_dir, d1)
555+
556+
self.assertEqual(TestgresConfig.cached_initdb_dir, d0)
557+
532558
def test_unix_sockets(self):
533559
with get_new_node() as node:
534560
node.init(unix_sockets=False, allow_streaming=True)

0 commit comments

Comments
 (0)