X Tutup
Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit e7c94df

Browse files
committed
Clean-up embedded tests
Clean-up embedded tests comments and variable types Remove TestFixture attribute. Optional since NUnit 2.5 https://nunit.org/index.php?p=testFixture&r=2.6.4
1 parent 04ce393 commit e7c94df

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed

src/embed_tests/dynamic.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace Python.EmbeddingTest
77
{
8-
[TestFixture]
98
public class dynamicTest
109
{
1110
private Py.GILState gil;
@@ -23,16 +22,16 @@ public void TearDown()
2322
}
2423

2524
/// <summary>
26-
/// Set the attribute of a pyobject with a .NET object.
25+
/// Set the attribute of a PyObject with a .NET object.
2726
/// </summary>
2827
[Test]
2928
public void AssignObject()
3029
{
31-
StringBuilder stream = new StringBuilder();
30+
var stream = new StringBuilder();
3231
dynamic sys = Py.Import("sys");
3332
sys.testattr = stream;
3433
// Check whether there are the same object.
35-
var _stream = sys.testattr.AsManagedObject(typeof(StringBuilder));
34+
dynamic _stream = sys.testattr.AsManagedObject(typeof(StringBuilder));
3635
Assert.AreEqual(_stream, stream);
3736

3837
PythonEngine.RunSimpleString(
@@ -42,7 +41,7 @@ public void AssignObject()
4241
}
4342

4443
/// <summary>
45-
/// Set the attribute of a pyobject to null.
44+
/// Set the attribute of a PyObject to null.
4645
/// </summary>
4746
[Test]
4847
public void AssignNone()
@@ -76,24 +75,24 @@ public void AssignPyObject()
7675
[Test]
7776
public void PassObjectInPython()
7877
{
79-
StringBuilder stream = new StringBuilder();
78+
var stream = new StringBuilder();
8079
dynamic sys = Py.Import("sys");
8180
sys.testattr1 = stream;
8281

83-
//Pass the .NET object in Python side
82+
// Pass the .NET object in Python side
8483
PythonEngine.RunSimpleString(
8584
"import sys\n" +
8685
"sys.testattr2 = sys.testattr1\n"
8786
);
8887

89-
//Compare in Python
88+
// Compare in Python
9089
PythonEngine.RunSimpleString(
9190
"import sys\n" +
9291
"sys.testattr3 = sys.testattr1 is sys.testattr2\n"
9392
);
9493
Assert.AreEqual(sys.testattr3.ToString(), "True");
9594

96-
//Compare in .NET
95+
// Compare in .NET
9796
Assert.AreEqual(sys.testattr1, sys.testattr2);
9897
}
9998

@@ -103,19 +102,19 @@ public void PassObjectInPython()
103102
[Test]
104103
public void PassPyObjectInNet()
105104
{
106-
StringBuilder stream = new StringBuilder();
105+
var stream = new StringBuilder();
107106
dynamic sys = Py.Import("sys");
108107
sys.testattr1 = stream;
109108
sys.testattr2 = sys.testattr1;
110109

111-
//Compare in Python
110+
// Compare in Python
112111
PyObject res = PythonEngine.RunString(
113112
"import sys\n" +
114113
"sys.testattr3 = sys.testattr1 is sys.testattr2\n"
115114
);
116115
Assert.AreEqual(sys.testattr3.ToString(), "True");
117116

118-
//Compare in .NET
117+
// Compare in .NET
119118
Assert.AreEqual(sys.testattr1, sys.testattr2);
120119
}
121120
}

src/embed_tests/pyimport.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace Python.EmbeddingTest
1717
/// | | - __init__.py
1818
/// | | - one.py
1919
/// </remarks>
20-
[TestFixture]
2120
public class PyImportTest
2221
{
2322
private IntPtr gs;

src/embed_tests/pyinitialize.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using NUnit.Framework;
23
using Python.Runtime;
34

@@ -51,24 +52,24 @@ public static void LoadSpecificArgs()
5152
//[Ignore("System.ArgumentException : Cannot pass a GCHandle across AppDomains")]
5253
public void ReInitialize()
5354
{
54-
string code = "from System import Int32\n";
55+
var code = "from System import Int32\n";
5556
PythonEngine.Initialize();
5657
using (Py.GIL())
5758
{
58-
//import any class or struct from .NET
59+
// Import any class or struct from .NET
5960
PythonEngine.RunSimpleString(code);
6061
}
6162
PythonEngine.Shutdown();
6263

6364
PythonEngine.Initialize();
6465
using (Py.GIL())
6566
{
66-
//Import a class/struct from .NET
67-
//This class/struct must be imported during the first initialization.
67+
// Import a class/struct from .NET
68+
// This class/struct must be imported during the first initialization.
6869
PythonEngine.RunSimpleString(code);
69-
//Create an instance of the class/struct
70-
//System.OverflowException Exception will be raised here.
71-
//If replacing int with Int64, OverflowException will be replaced with AppDomain exception.
70+
// Create an instance of the class/struct
71+
// System.OverflowException Exception will be raised here.
72+
// If replacing int with Int64, OverflowException will be replaced with AppDomain exception.
7273
PythonEngine.RunSimpleString("Int32(1)");
7374
}
7475
PythonEngine.Shutdown();

src/embed_tests/pyiter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using NUnit.Framework;
34
using Python.Runtime;

src/embed_tests/pylong.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using NUnit.Framework;
23
using Python.Runtime;
34

src/embed_tests/pyobject.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using NUnit.Framework;
23
using Python.Runtime;
34

src/embed_tests/pythonexception.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ namespace Python.EmbeddingTest
1111
/// Keeping this in the old-style SetUp/TearDown
1212
/// to ensure that setup still works.
1313
/// </remarks>
14-
[TestFixture]
1514
public class PythonExceptionTest
1615
{
1716
private IntPtr gs;

src/embed_tests/pytuple.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using NUnit.Framework;
23
using Python.Runtime;
34

0 commit comments

Comments
 (0)
X Tutup