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
5
5
6
6
public class References
7
7
{
8
- private Py . GILState _gs ;
9
-
10
- [ SetUp ]
8
+ [ OneTimeSetUp ]
11
9
public void SetUp ( )
12
10
{
13
- _gs = Py . GIL ( ) ;
11
+ PythonEngine . Initialize ( ) ;
14
12
}
15
13
16
- [ TearDown ]
14
+ [ OneTimeTearDown ]
17
15
public void Dispose ( )
18
16
{
19
- _gs . Dispose ( ) ;
17
+ PythonEngine . Shutdown ( ) ;
20
18
}
21
19
22
20
[ Test ]
Original file line number Diff line number Diff line change @@ -13,18 +13,16 @@ namespace Python.EmbeddingTest
13
13
{
14
14
public class TestNativeTypeOffset
15
15
{
16
- private Py . GILState _gs ;
17
-
18
- [ SetUp ]
16
+ [ OneTimeSetUp ]
19
17
public void SetUp ( )
20
18
{
21
- _gs = Py . GIL ( ) ;
19
+ PythonEngine . Initialize ( ) ;
22
20
}
23
21
24
- [ TearDown ]
22
+ [ OneTimeTearDown ]
25
23
public void Dispose ( )
26
24
{
27
- _gs . Dispose ( ) ;
25
+ PythonEngine . Shutdown ( ) ;
28
26
}
29
27
30
28
/// <summary>
Original file line number Diff line number Diff line change @@ -6,19 +6,15 @@ namespace Python.EmbeddingTest
6
6
{
7
7
public class TestPythonException
8
8
{
9
- private IntPtr _gs ;
10
-
11
- [ SetUp ]
9
+ [ OneTimeSetUp ]
12
10
public void SetUp ( )
13
11
{
14
12
PythonEngine . Initialize ( ) ;
15
- _gs = PythonEngine . AcquireLock ( ) ;
16
13
}
17
14
18
- [ TearDown ]
15
+ [ OneTimeTearDown ]
19
16
public void Dispose ( )
20
17
{
21
- PythonEngine . ReleaseLock ( _gs ) ;
22
18
PythonEngine . Shutdown ( ) ;
23
19
}
24
20
Original file line number Diff line number Diff line change @@ -7,28 +7,16 @@ namespace Python.EmbeddingTest
7
7
{
8
8
public class DynamicTest
9
9
{
10
- private Py . GILState _gs ;
11
-
12
- [ SetUp ]
10
+ [ OneTimeSetUp ]
13
11
public void SetUp ( )
14
12
{
15
- try {
16
- _gs = Py . GIL ( ) ;
17
- } catch ( Exception e ) {
18
- Console . WriteLine ( $ "exception in SetUp: { e } ") ;
19
- throw ;
20
- }
13
+ PythonEngine . Initialize ( ) ;
21
14
}
22
15
23
- [ TearDown ]
16
+ [ OneTimeTearDown ]
24
17
public void Dispose ( )
25
18
{
26
- try {
27
- _gs . Dispose ( ) ;
28
- } catch ( Exception e ) {
29
- Console . WriteLine ( $ "exception in TearDown: { e } ") ;
30
- throw ;
31
- }
19
+ PythonEngine . Shutdown ( ) ;
32
20
}
33
21
34
22
/// <summary>
Original file line number Diff line number Diff line change @@ -19,13 +19,10 @@ namespace Python.EmbeddingTest
19
19
/// </remarks>
20
20
public class PyImportTest
21
21
{
22
- private IntPtr _gs ;
23
-
24
- [ SetUp ]
22
+ [ OneTimeSetUp ]
25
23
public void SetUp ( )
26
24
{
27
25
PythonEngine . Initialize ( ) ;
28
- _gs = PythonEngine . AcquireLock ( ) ;
29
26
30
27
/* Append the tests directory to sys.path
31
28
* using reflection to circumvent the private
@@ -41,10 +38,9 @@ public void SetUp()
41
38
Runtime . Runtime . XDecref ( str ) ;
42
39
}
43
40
44
- [ TearDown ]
41
+ [ OneTimeTearDown ]
45
42
public void Dispose ( )
46
43
{
47
- PythonEngine . ReleaseLock ( _gs ) ;
48
44
PythonEngine . Shutdown ( ) ;
49
45
}
50
46
Original file line number Diff line number Diff line change @@ -6,18 +6,16 @@ namespace Python.EmbeddingTest
6
6
{
7
7
public class RunStringTest
8
8
{
9
- private Py . GILState _gs ;
10
-
11
- [ SetUp ]
9
+ [ OneTimeSetUp ]
12
10
public void SetUp ( )
13
11
{
14
- _gs = Py . GIL ( ) ;
12
+ PythonEngine . Initialize ( ) ;
15
13
}
16
14
17
- [ TearDown ]
15
+ [ OneTimeTearDown ]
18
16
public void Dispose ( )
19
17
{
20
- _gs . Dispose ( ) ;
18
+ PythonEngine . Shutdown ( ) ;
21
19
}
22
20
23
21
[ Test ]
You can’t perform that action at this time.
0 commit comments