Skip to content

Commit 3058bf7

Browse files
committed
Cleanup testing format
1 parent 905884c commit 3058bf7

File tree

12 files changed

+45
-43
lines changed

12 files changed

+45
-43
lines changed

src/embed_tests/pyimport.cs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ public void SetUp()
1818
PythonEngine.Initialize();
1919
gs = PythonEngine.AcquireLock();
2020

21-
/*
22-
* Append the tests directory to sys.path
23-
* using reflection to circumvent the private modifiers placed on most Runtime methods.
21+
/* Append the tests directory to sys.path
22+
* using reflection to circumvent the private
23+
* modifiers placed on most Runtime methods.
2424
*/
2525
const string s = @"../../../../tests";
2626

27-
var testPath = Path.Combine(
28-
TestContext.CurrentContext.TestDirectory, s
29-
);
27+
string testPath = Path.Combine(TestContext.CurrentContext.TestDirectory, s);
3028

3129
IntPtr str = Runtime.Runtime.PyString_FromString(testPath);
3230
IntPtr path = Runtime.Runtime.PySys_GetObject("path");
@@ -44,13 +42,12 @@ public void TearDown()
4442
/// Test subdirectory import
4543
/// </summary>
4644
/// <remarks>
47-
/// The required directory structure was added to the \trunk\pythonnet\src\tests directory:
48-
///
49-
/// PyImportTest/
50-
/// __init__.py
51-
/// test/
52-
/// __init__.py
53-
/// one.py
45+
/// The required directory structure was added to .\pythonnet\src\tests\ directory:
46+
/// + PyImportTest/
47+
/// | - __init__.py
48+
/// | + test/
49+
/// | | - __init__.py
50+
/// | | - one.py
5451
/// </remarks>
5552
[Test]
5653
public void TestDottedName()

src/embed_tests/pyiter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ public void TearDown()
2727
[Test]
2828
public void TestOnPyList()
2929
{
30-
PyList list = new PyList();
30+
var list = new PyList();
3131
list.Append(new PyString("foo"));
3232
list.Append(new PyString("bar"));
3333
list.Append(new PyString("baz"));
34-
List<string> result = new List<string>();
34+
var result = new List<string>();
3535
foreach (PyObject item in list)
3636
{
3737
result.Add(item.ToString());

src/embed_tests/pythonexception.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void TearDown()
2626
[Test]
2727
public void TestMessage()
2828
{
29-
PyList list = new PyList();
29+
var list = new PyList();
3030
try
3131
{
3232
PyObject junk = list[0];
@@ -40,7 +40,7 @@ public void TestMessage()
4040
[Test]
4141
public void TestNoError()
4242
{
43-
PythonException e = new PythonException(); //There is no PyErr to fetch
43+
var e = new PythonException(); //There is no PyErr to fetch
4444
Assert.AreEqual("", e.Message);
4545
}
4646
}

src/testing/callbacktest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public class SelfCallbackTest
3737
public void Callback(PyObject self)
3838
{
3939
using (Py.GIL())
40+
{
4041
((dynamic)self).PyCallback(self);
42+
}
4143
}
4244
}
4345
}

src/testing/classtest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ public class ClassTest
1010
{
1111
public static ArrayList GetArrayList()
1212
{
13-
ArrayList list = new ArrayList();
14-
for (int i = 0; i < 10; i++)
13+
var list = new ArrayList();
14+
for (var i = 0; i < 10; i++)
1515
{
1616
list.Add(i);
1717
}
@@ -20,7 +20,7 @@ public static ArrayList GetArrayList()
2020

2121
public static Hashtable GetHashtable()
2222
{
23-
Hashtable dict = new Hashtable();
23+
var dict = new Hashtable();
2424
dict.Add("one", 1);
2525
dict.Add("two", 2);
2626
dict.Add("three", 3);
@@ -31,7 +31,7 @@ public static Hashtable GetHashtable()
3131

3232
public static IEnumerator GetEnumerator()
3333
{
34-
string temp = "test string";
34+
var temp = "test string";
3535
return temp.GetEnumerator();
3636
}
3737
}

src/testing/constructortests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class EnumConstructorTest
1313

1414
public EnumConstructorTest(TypeCode v)
1515
{
16-
this.value = v;
16+
value = v;
1717
}
1818
}
1919

@@ -24,7 +24,7 @@ public class FlagsConstructorTest
2424

2525
public FlagsConstructorTest(FileAccess v)
2626
{
27-
this.value = v;
27+
value = v;
2828
}
2929
}
3030

@@ -35,7 +35,7 @@ public class StructConstructorTest
3535

3636
public StructConstructorTest(Guid v)
3737
{
38-
this.value = v;
38+
value = v;
3939
}
4040
}
4141

@@ -46,7 +46,7 @@ public class SubclassConstructorTest
4646

4747
public SubclassConstructorTest(Exception v)
4848
{
49-
this.value = v;
49+
value = v;
5050
}
5151
}
5252
}

src/testing/eventtest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class EventTest
3333

3434
public EventTest()
3535
{
36-
this.value = 0;
36+
value = 0;
3737
}
3838

3939
static EventTest()
@@ -80,7 +80,7 @@ protected static void OnProtectedStaticEvent(EventArgsTest e)
8080

8181
public void GenericHandler(object sender, EventArgsTest e)
8282
{
83-
this.value = e.value;
83+
value = e.value;
8484
}
8585

8686
public static void StaticHandler(object sender, EventArgsTest e)
@@ -91,8 +91,8 @@ public static void StaticHandler(object sender, EventArgsTest e)
9191
public static void ShutUpCompiler()
9292
{
9393
// Quiet compiler warnings.
94-
EventTest e = new EventTest();
95-
EventHandlerTest f = new EventHandlerTest(e.GenericHandler);
94+
var e = new EventTest();
95+
EventHandlerTest f = e.GenericHandler;
9696
ProtectedStaticEvent += f;
9797
InternalStaticEvent += f;
9898
PrivateStaticEvent += f;
@@ -109,7 +109,7 @@ public class EventArgsTest : EventArgs
109109

110110
public EventArgsTest(int v)
111111
{
112-
this.value = v;
112+
value = v;
113113
}
114114
}
115115
}

src/testing/exceptiontest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void ThrowChainedExceptions()
7878

7979
public class ExtendedException : OverflowException
8080
{
81-
public ExtendedException() : base()
81+
public ExtendedException()
8282
{
8383
}
8484

src/testing/generictest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class GenericTypeDefinition<T, U>
2121

2222
public GenericTypeDefinition(T arg1, U arg2)
2323
{
24-
this.value1 = arg1;
25-
this.value2 = arg2;
24+
value1 = arg1;
25+
value2 = arg2;
2626
}
2727
}
2828

@@ -34,7 +34,7 @@ public class DerivedFromOpenGeneric<V, W> :
3434
public DerivedFromOpenGeneric(int arg1, V arg2, W arg3) :
3535
base(arg1, arg2)
3636
{
37-
this.value3 = arg3;
37+
value3 = arg3;
3838
}
3939
}
4040

src/testing/moduletest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Reflection;
23
using System.Threading;
34

45
namespace Python.Test
@@ -11,9 +12,9 @@ public static void RunThreads()
1112
{
1213
_thread = new Thread(() =>
1314
{
14-
var appdomain = AppDomain.CurrentDomain;
15-
var assemblies = appdomain.GetAssemblies();
16-
foreach (var assembly in assemblies)
15+
AppDomain appdomain = AppDomain.CurrentDomain;
16+
Assembly[] assemblies = appdomain.GetAssemblies();
17+
foreach (Assembly assembly in assemblies)
1718
{
1819
assembly.GetTypes();
1920
}

0 commit comments

Comments
 (0)