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

Skip to content
Prev Previous commit
Next Next commit
Add test on os.environb.refresh() with unsetenv()
  • Loading branch information
vstinner committed Jun 10, 2024
commit 6aaadc3bb655fd0db8ffa400538b0c731c1b00dd
10 changes: 9 additions & 1 deletion Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def test_refresh(self):
self.assertNotIn(b'test_env', os.environb)

if has_environb:
# test os.environb.refresh()
# test os.environb.refresh() with putenv()
os.environb[b'test_env'] = b'python_value2'
os.putenv("test_env", "new_value2")
self.assertEqual(os.environb[b'test_env'], b'python_value2')
Expand All @@ -1336,6 +1336,14 @@ def test_refresh(self):
self.assertEqual(os.environb[b'test_env'], b'new_value2')
self.assertEqual(os.environ['test_env'], 'new_value2')

# test os.environb.refresh() with unsetenv()
os.unsetenv('test_env')
self.assertEqual(os.environb[b'test_env'], b'new_value')
self.assertEqual(os.environ['test_env'], 'new_value')

os.environb.refresh()
self.assertNotIn(b'test_env', os.environb)
self.assertNotIn('test_env', os.environ)

class WalkTests(unittest.TestCase):
"""Tests for os.walk()."""
Expand Down