Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85adb1b

Browse files
committed
ensure all unit tests have similar SetUp and TearDown procedures when a running PythonEngine is needed
1 parent2679c19 commit85adb1b

File tree

6 files changed

+20
-46
lines changed

6 files changed

+20
-46
lines changed

‎src/embed_tests/References.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ namespace Python.EmbeddingTest
55

66
publicclassReferences
77
{
8-
privatePy.GILState_gs;
9-
10-
[SetUp]
8+
[OneTimeSetUp]
119
publicvoidSetUp()
1210
{
13-
_gs=Py.GIL();
11+
PythonEngine.Initialize();
1412
}
1513

16-
[TearDown]
14+
[OneTimeTearDown]
1715
publicvoidDispose()
1816
{
19-
_gs.Dispose();
17+
PythonEngine.Shutdown();
2018
}
2119

2220
[Test]

‎src/embed_tests/TestNativeTypeOffset.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@ namespace Python.EmbeddingTest
1313
{
1414
publicclassTestNativeTypeOffset
1515
{
16-
privatePy.GILState_gs;
17-
18-
[SetUp]
16+
[OneTimeSetUp]
1917
publicvoidSetUp()
2018
{
21-
_gs=Py.GIL();
19+
PythonEngine.Initialize();
2220
}
2321

24-
[TearDown]
22+
[OneTimeTearDown]
2523
publicvoidDispose()
2624
{
27-
_gs.Dispose();
25+
PythonEngine.Shutdown();
2826
}
2927

3028
/// <summary>

‎src/embed_tests/TestPythonException.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ namespace Python.EmbeddingTest
66
{
77
publicclassTestPythonException
88
{
9-
privateIntPtr_gs;
10-
11-
[SetUp]
9+
[OneTimeSetUp]
1210
publicvoidSetUp()
1311
{
1412
PythonEngine.Initialize();
15-
_gs=PythonEngine.AcquireLock();
1613
}
1714

18-
[TearDown]
15+
[OneTimeTearDown]
1916
publicvoidDispose()
2017
{
21-
PythonEngine.ReleaseLock(_gs);
2218
PythonEngine.Shutdown();
2319
}
2420

‎src/embed_tests/dynamic.cs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,16 @@ namespace Python.EmbeddingTest
77
{
88
publicclassDynamicTest
99
{
10-
privatePy.GILState_gs;
11-
12-
[SetUp]
10+
[OneTimeSetUp]
1311
publicvoidSetUp()
1412
{
15-
try{
16-
_gs=Py.GIL();
17-
}catch(Exceptione){
18-
Console.WriteLine($"exception in SetUp:{e}");
19-
throw;
20-
}
13+
PythonEngine.Initialize();
2114
}
2215

23-
[TearDown]
16+
[OneTimeTearDown]
2417
publicvoidDispose()
2518
{
26-
try{
27-
_gs.Dispose();
28-
}catch(Exceptione){
29-
Console.WriteLine($"exception in TearDown:{e}");
30-
throw;
31-
}
19+
PythonEngine.Shutdown();
3220
}
3321

3422
/// <summary>

‎src/embed_tests/pyimport.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@ namespace Python.EmbeddingTest
1919
/// </remarks>
2020
publicclassPyImportTest
2121
{
22-
privateIntPtr_gs;
23-
24-
[SetUp]
22+
[OneTimeSetUp]
2523
publicvoidSetUp()
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
publicvoidDispose()
4643
{
47-
PythonEngine.ReleaseLock(_gs);
4844
PythonEngine.Shutdown();
4945
}
5046

‎src/embed_tests/pyrunstring.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ namespace Python.EmbeddingTest
66
{
77
publicclassRunStringTest
88
{
9-
privatePy.GILState_gs;
10-
11-
[SetUp]
9+
[OneTimeSetUp]
1210
publicvoidSetUp()
1311
{
14-
_gs=Py.GIL();
12+
PythonEngine.Initialize();
1513
}
1614

17-
[TearDown]
15+
[OneTimeTearDown]
1816
publicvoidDispose()
1917
{
20-
_gs.Dispose();
18+
PythonEngine.Shutdown();
2119
}
2220

2321
[Test]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp