Skip to content

Commit 7ab9abe

Browse files
committed
add test for pragma _reopen_tracker
missed committing it with the code change. Note _reopen_tracker is a negative feature flag. It should go away if nobody reports an error with the new tracker open caching code path.
1 parent 333f32b commit 7ab9abe

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

test/test_admin.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,58 @@ def testFilter(self):
803803
print(err.getvalue().strip())
804804
self.assertEqual(out, "issue1:issue2")
805805

806+
def testPragma_reopen_tracker(self):
807+
"""test that _reopen_tracker works.
808+
"""
809+
if self.backend not in ['anydbm']:
810+
self.skipTest("For speed only run test with anydbm.")
811+
812+
orig_input = AdminTool.my_input
813+
814+
# must set verbose to see _reopen_tracker hidden setting.
815+
# and to get "Reopening tracker" verbose log output
816+
inputs = iter(["pragma verbose=true", "pragma list", "quit"])
817+
AdminTool.my_input = lambda _self, _prompt: next(inputs)
818+
819+
self.install_init()
820+
self.admin=AdminTool()
821+
sys.argv=['main', '-i', self.dirname]
822+
823+
with captured_output() as (out, err):
824+
ret = self.admin.main()
825+
826+
out = out.getvalue().strip().split('\n')
827+
828+
print(ret)
829+
self.assertTrue(ret == 0)
830+
expected = ' _reopen_tracker=False'
831+
self.assertIn(expected, out)
832+
self.assertIn('descriptions...', out[-1])
833+
self.assertNotIn('Reopening tracker', out)
834+
835+
# -----
836+
inputs = iter(["pragma verbose=true", "pragma _reopen_tracker=True",
837+
"pragma list", "quit"])
838+
AdminTool.my_input = lambda _self, _prompt: next(inputs)
839+
840+
self.install_init()
841+
self.admin=AdminTool()
842+
sys.argv=['main', '-i', self.dirname]
843+
844+
with captured_output() as (out, err):
845+
ret = self.admin.main()
846+
847+
out = out.getvalue().strip().split('\n')
848+
849+
print(ret)
850+
self.assertTrue(ret == 0)
851+
self.assertEqual('Reopening tracker', out[2])
852+
expected = ' _reopen_tracker=True'
853+
self.assertIn(expected, out)
854+
855+
# -----
856+
AdminTool.my_input = orig_input
857+
806858
def testPragma(self):
807859
"""Uses interactive mode since pragmas only apply when using multiple
808860
commands.

0 commit comments

Comments
 (0)