Skip to content

Commit 5f6891e

Browse files
committed
[Python] Fix global directory setting in root_module test
Doing `ROOT.gDirectory = ROOT.nullptr` is problematic because it replaces the `TDirectoryPythonAdapter` instance that makes `gDirectory` work as intended on the Python side, so this pattern can't be used. Follows up on 2659fe3.
1 parent b56b49e commit 5f6891e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

bindings/pyroot/pythonizations/test/root_module.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ def test_lazy_gdirectory(self):
150150
self.assertEqual(gDirectory_1, gDirectory_2)
151151
self.assertNotEqual(gDirectory_1, ROOT.gROOT)
152152

153-
# If we re-assign the gDirectory now, it should be considered
154-
ROOT.gDirectory = ROOT.nullptr
155-
self.assertEqual(gDirectory_1, ROOT.nullptr)
156-
self.assertEqual(gDirectory_2, ROOT.nullptr)
153+
# If we reset the global directory to nullptr now, it should be considered
154+
with ROOT.TDirectory.TContext(ROOT.nullptr):
155+
self.assertEqual(gDirectory_1, ROOT.nullptr)
156+
self.assertEqual(gDirectory_2, ROOT.nullptr)
157157

158158

159159
if __name__ == "__main__":

0 commit comments

Comments
 (0)