File tree Expand file tree Collapse file tree 6 files changed +20
-46
lines changed
Expand file tree Collapse file tree 6 files changed +20
-46
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,16 @@ namespace Python.EmbeddingTest
55
66 public class References
77 {
8- private Py . GILState _gs ;
9-
10- [ SetUp ]
8+ [ OneTimeSetUp ]
119 public void SetUp ( )
1210 {
13- _gs = Py . GIL ( ) ;
11+ PythonEngine . Initialize ( ) ;
1412 }
1513
16- [ TearDown ]
14+ [ OneTimeTearDown ]
1715 public void Dispose ( )
1816 {
19- _gs . Dispose ( ) ;
17+ PythonEngine . Shutdown ( ) ;
2018 }
2119
2220 [ Test ]
Original file line number Diff line number Diff line change @@ -13,18 +13,16 @@ namespace Python.EmbeddingTest
1313{
1414 public class TestNativeTypeOffset
1515 {
16- private Py . GILState _gs ;
17-
18- [ SetUp ]
16+ [ OneTimeSetUp ]
1917 public void SetUp ( )
2018 {
21- _gs = Py . GIL ( ) ;
19+ PythonEngine . Initialize ( ) ;
2220 }
2321
24- [ TearDown ]
22+ [ OneTimeTearDown ]
2523 public void Dispose ( )
2624 {
27- _gs . Dispose ( ) ;
25+ PythonEngine . Shutdown ( ) ;
2826 }
2927
3028 /// <summary>
Original file line number Diff line number Diff line change @@ -6,19 +6,15 @@ namespace Python.EmbeddingTest
66{
77 public class TestPythonException
88 {
9- private IntPtr _gs ;
10-
11- [ SetUp ]
9+ [ OneTimeSetUp ]
1210 public void SetUp ( )
1311 {
1412 PythonEngine . Initialize ( ) ;
15- _gs = PythonEngine . AcquireLock ( ) ;
1613 }
1714
18- [ TearDown ]
15+ [ OneTimeTearDown ]
1916 public void Dispose ( )
2017 {
21- PythonEngine . ReleaseLock ( _gs ) ;
2218 PythonEngine . Shutdown ( ) ;
2319 }
2420
Original file line number Diff line number Diff line change @@ -7,28 +7,16 @@ namespace Python.EmbeddingTest
77{
88 public class DynamicTest
99 {
10- private Py . GILState _gs ;
11-
12- [ SetUp ]
10+ [ OneTimeSetUp ]
1311 public void SetUp ( )
1412 {
15- try {
16- _gs = Py . GIL ( ) ;
17- } catch ( Exception e ) {
18- Console . WriteLine ( $ "exception in SetUp: { e } ") ;
19- throw ;
20- }
13+ PythonEngine . Initialize ( ) ;
2114 }
2215
23- [ TearDown ]
16+ [ OneTimeTearDown ]
2417 public void Dispose ( )
2518 {
26- try {
27- _gs . Dispose ( ) ;
28- } catch ( Exception e ) {
29- Console . WriteLine ( $ "exception in TearDown: { e } ") ;
30- throw ;
31- }
19+ PythonEngine . Shutdown ( ) ;
3220 }
3321
3422 /// <summary>
Original file line number Diff line number Diff line change @@ -19,13 +19,10 @@ namespace Python.EmbeddingTest
1919 /// </remarks>
2020 public class PyImportTest
2121 {
22- private IntPtr _gs ;
23-
24- [ SetUp ]
22+ [ OneTimeSetUp ]
2523 public void SetUp ( )
2624 {
2725 PythonEngine . Initialize ( ) ;
28- _gs = PythonEngine . AcquireLock ( ) ;
2926
3027 /* Append the tests directory to sys.path
3128 * using reflection to circumvent the private
@@ -41,10 +38,9 @@ public void SetUp()
4138 Runtime . Runtime . XDecref ( str ) ;
4239 }
4340
44- [ TearDown ]
41+ [ OneTimeTearDown ]
4542 public void Dispose ( )
4643 {
47- PythonEngine . ReleaseLock ( _gs ) ;
4844 PythonEngine . Shutdown ( ) ;
4945 }
5046
Original file line number Diff line number Diff line change @@ -6,18 +6,16 @@ namespace Python.EmbeddingTest
66{
77 public class RunStringTest
88 {
9- private Py . GILState _gs ;
10-
11- [ SetUp ]
9+ [ OneTimeSetUp ]
1210 public void SetUp ( )
1311 {
14- _gs = Py . GIL ( ) ;
12+ PythonEngine . Initialize ( ) ;
1513 }
1614
17- [ TearDown ]
15+ [ OneTimeTearDown ]
1816 public void Dispose ( )
1917 {
20- _gs . Dispose ( ) ;
18+ PythonEngine . Shutdown ( ) ;
2119 }
2220
2321 [ Test ]
You can’t perform that action at this time.
0 commit comments