|
5 | 5 | import os
|
6 | 6 | import typing as t
|
7 | 7 |
|
8 |
| -import pytest |
9 |
| - |
10 | 8 | from libtmux.test.environment import EnvironmentVarGuard
|
11 | 9 |
|
12 | 10 |
|
@@ -116,38 +114,38 @@ def test_environment_var_guard_unset_and_reset() -> None:
|
116 | 114 | def test_environment_var_guard_exit_with_exception() -> None:
|
117 | 115 | """Test __exit__ method with exception parameters."""
|
118 | 116 | env = EnvironmentVarGuard()
|
119 |
| - |
| 117 | + |
120 | 118 | # Set up test variables
|
121 | 119 | os.environ["TEST_VAR"] = "original_value"
|
122 | 120 | env.set("TEST_VAR", "new_value")
|
123 |
| - |
| 121 | + |
124 | 122 | # Call __exit__ with exception parameters
|
125 | 123 | env.__exit__(
|
126 |
| - t.cast(t.Type[BaseException], RuntimeError), |
| 124 | + t.cast(type[BaseException], RuntimeError), |
127 | 125 | RuntimeError("Test exception"),
|
128 | 126 | None,
|
129 | 127 | )
|
130 |
| - |
| 128 | + |
131 | 129 | # Verify cleanup still happened
|
132 | 130 | assert os.environ["TEST_VAR"] == "original_value"
|
133 | 131 |
|
134 | 132 |
|
135 | 133 | def test_environment_var_guard_unset_previously_set() -> None:
|
136 | 134 | """Test unsetting a variable that was previously set in the same context."""
|
137 | 135 | env = EnvironmentVarGuard()
|
138 |
| - |
| 136 | + |
139 | 137 | # Make sure the variable doesn't exist initially
|
140 | 138 | if "TEST_NEW_VAR" in os.environ:
|
141 | 139 | del os.environ["TEST_NEW_VAR"]
|
142 |
| - |
| 140 | + |
143 | 141 | # Set a new variable
|
144 | 142 | env.set("TEST_NEW_VAR", "new_value")
|
145 | 143 | assert "TEST_NEW_VAR" in os.environ
|
146 | 144 | assert os.environ["TEST_NEW_VAR"] == "new_value"
|
147 |
| - |
| 145 | + |
148 | 146 | # Now unset it - this should hit line 57
|
149 | 147 | env.unset("TEST_NEW_VAR")
|
150 | 148 | assert "TEST_NEW_VAR" not in os.environ
|
151 |
| - |
| 149 | + |
152 | 150 | # No need to check after cleanup since the variable was never in the environment
|
153 | 151 | # before we started
|
0 commit comments