Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 905884c

Browse files
committed
Merge pull request #329 from vmuriart/unittests
Closes #329
2 parents 43de985 + 400f688 commit 905884c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3455
-4350
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ addons:
2525
- nunit-console
2626

2727
install:
28-
- pip install pycparser coverage codecov six
28+
- pip install pycparser coverage codecov
2929
- coverage run setup.py build_ext --inplace
3030

3131
script:

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ init:
4646

4747
install:
4848
# install for wheels & coverage
49-
- pip install --upgrade pip wheel coverage codecov six
49+
- pip install --upgrade pip wheel coverage codecov
5050

5151
# Install OpenCover. Can't put on packages.config; not Linux/Mono compatible
5252
- .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages

src/testing/arraytest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections;
3-
41
namespace Python.Test
52
{
63
//========================================================================
@@ -318,4 +315,4 @@ public static Spam[][] EchoRangeAA(Spam[][] items)
318315
return items;
319316
}
320317
}
321-
}
318+
}

src/testing/callbacktest.cs

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using Python.Runtime;
52

63
namespace Python.Test
74
{
@@ -13,32 +10,33 @@ public class CallbackTest
1310
{
1411
public string Call_simpleDefaultArg_WithNull(string moduleName)
1512
{
16-
using (Runtime.Py.GIL())
13+
using (Py.GIL())
1714
{
18-
dynamic module = Runtime.Py.Import(moduleName);
15+
dynamic module = Py.Import(moduleName);
1916
return module.simpleDefaultArg(null);
2017
}
2118
}
19+
2220
public string Call_simpleDefaultArg_WithEmptyArgs(string moduleName)
2321
{
24-
using (Runtime.Py.GIL())
22+
using (Py.GIL())
2523
{
26-
dynamic module = Runtime.Py.Import(moduleName);
24+
dynamic module = Py.Import(moduleName);
2725
return module.simpleDefaultArg();
2826
}
2927
}
3028
}
3129

3230
//==========================================================================
3331
// Tests calling from Python into C# and back into Python using a PyObject.
34-
// SelfCallbackTest should be inherited by a Python class.
32+
// SelfCallbackTest should be inherited by a Python class.
3533
// Used in test_class.py / testCallback
3634
//==========================================================================
3735
public class SelfCallbackTest
3836
{
39-
public void Callback(Runtime.PyObject self)
37+
public void Callback(PyObject self)
4038
{
41-
using (Runtime.Py.GIL())
39+
using (Py.GIL())
4240
((dynamic)self).PyCallback(self);
4341
}
4442
}

src/testing/classtest.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections;
32

43
namespace Python.Test
@@ -61,4 +60,4 @@ public ClassCtorTest2(string v)
6160
internal class InternalClass
6261
{
6362
}
64-
}
63+
}

src/testing/constructortests.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.Collections;
32
using System.IO;
43

54
namespace Python.Test
@@ -50,4 +49,4 @@ public SubclassConstructorTest(Exception v)
5049
this.value = v;
5150
}
5251
}
53-
}
52+
}

src/testing/conversiontest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
3-
41
namespace Python.Test
52
{
63
//========================================================================
@@ -58,4 +55,4 @@ public string GetValue()
5855
return value;
5956
}
6057
}
61-
}
58+
}

src/testing/delegatetest.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Python.Test
42
{
53
//========================================================================
@@ -60,4 +58,4 @@ public bool CallBoolDelegate(BoolDelegate d)
6058
return d();
6159
}
6260
}
63-
}
61+
}

src/testing/doctest.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ namespace Python.Test
88

99
// Classes with a constructor have their docstring set to the ctor signature.
1010
// Test if a class has an explicit doc string it gets set correctly.
11-
[DocStringAttribute("DocWithCtorTest Class")]
11+
[DocString("DocWithCtorTest Class")]
1212
public class DocWithCtorTest
1313
{
1414
public DocWithCtorTest()
1515
{
1616
}
1717

18-
[DocStringAttribute("DocWithCtorTest TestMethod")]
18+
[DocString("DocWithCtorTest TestMethod")]
1919
public void TestMethod()
2020
{
2121
}
2222

23-
[DocStringAttribute("DocWithCtorTest StaticTestMethod")]
23+
[DocString("DocWithCtorTest StaticTestMethod")]
2424
public static void StaticTestMethod()
2525
{
2626
}
@@ -41,17 +41,17 @@ public static void StaticTestMethod(double a, int b)
4141
}
4242
}
4343

44-
[DocStringAttribute("DocWithoutCtorTest Class")]
44+
[DocString("DocWithoutCtorTest Class")]
4545
public class DocWithoutCtorTest
4646
{
47-
[DocStringAttribute("DocWithoutCtorTest TestMethod")]
47+
[DocString("DocWithoutCtorTest TestMethod")]
4848
public void TestMethod()
4949
{
5050
}
5151

52-
[DocStringAttribute("DocWithoutCtorTest StaticTestMethod")]
52+
[DocString("DocWithoutCtorTest StaticTestMethod")]
5353
public static void StaticTestMethod()
5454
{
5555
}
5656
}
57-
}
57+
}

src/testing/enumtest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public enum ULongEnum : ulong
8686
Five
8787
}
8888

89-
[FlagsAttribute]
89+
[Flags]
9090
public enum FlagsEnum
9191
{
9292
Zero,
@@ -96,4 +96,4 @@ public enum FlagsEnum
9696
Four,
9797
Five
9898
}
99-
}
99+
}

src/testing/eventtest.cs

+19-19
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ namespace Python.Test
66
// Supports CLR event unit tests.
77
//========================================================================
88

9-
public delegate void TestEventHandler(object sender, TestEventArgs e);
9+
public delegate void EventHandlerTest(object sender, EventArgsTest e);
1010

1111

1212
public class EventTest
1313
{
14-
public static event TestEventHandler PublicStaticEvent;
14+
public static event EventHandlerTest PublicStaticEvent;
1515

16-
protected static event TestEventHandler ProtectedStaticEvent;
16+
protected static event EventHandlerTest ProtectedStaticEvent;
1717

18-
internal static event TestEventHandler InternalStaticEvent;
18+
internal static event EventHandlerTest InternalStaticEvent;
1919

20-
private static event TestEventHandler PrivateStaticEvent;
20+
private static event EventHandlerTest PrivateStaticEvent;
2121

22-
public event TestEventHandler PublicEvent;
22+
public event EventHandlerTest PublicEvent;
2323

24-
protected event TestEventHandler ProtectedEvent;
24+
protected event EventHandlerTest ProtectedEvent;
2525

26-
internal event TestEventHandler InternalEvent;
26+
internal event EventHandlerTest InternalEvent;
2727

28-
private event TestEventHandler PrivateEvent;
28+
private event EventHandlerTest PrivateEvent;
2929

3030

3131
public static int s_value;
@@ -42,7 +42,7 @@ static EventTest()
4242
}
4343

4444

45-
public void OnPublicEvent(TestEventArgs e)
45+
public void OnPublicEvent(EventArgsTest e)
4646
{
4747
if (PublicEvent != null)
4848
{
@@ -51,7 +51,7 @@ public void OnPublicEvent(TestEventArgs e)
5151
}
5252

5353

54-
public void OnProtectedEvent(TestEventArgs e)
54+
public void OnProtectedEvent(EventArgsTest e)
5555
{
5656
if (ProtectedEvent != null)
5757
{
@@ -60,7 +60,7 @@ public void OnProtectedEvent(TestEventArgs e)
6060
}
6161

6262

63-
public static void OnPublicStaticEvent(TestEventArgs e)
63+
public static void OnPublicStaticEvent(EventArgsTest e)
6464
{
6565
if (PublicStaticEvent != null)
6666
{
@@ -69,7 +69,7 @@ public static void OnPublicStaticEvent(TestEventArgs e)
6969
}
7070

7171

72-
protected static void OnProtectedStaticEvent(TestEventArgs e)
72+
protected static void OnProtectedStaticEvent(EventArgsTest e)
7373
{
7474
if (ProtectedStaticEvent != null)
7575
{
@@ -78,12 +78,12 @@ protected static void OnProtectedStaticEvent(TestEventArgs e)
7878
}
7979

8080

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

86-
public static void StaticHandler(object sender, TestEventArgs e)
86+
public static void StaticHandler(object sender, EventArgsTest e)
8787
{
8888
s_value = e.value;
8989
}
@@ -92,7 +92,7 @@ public static void ShutUpCompiler()
9292
{
9393
// Quiet compiler warnings.
9494
EventTest e = new EventTest();
95-
TestEventHandler f = new TestEventHandler(e.GenericHandler);
95+
EventHandlerTest f = new EventHandlerTest(e.GenericHandler);
9696
ProtectedStaticEvent += f;
9797
InternalStaticEvent += f;
9898
PrivateStaticEvent += f;
@@ -103,13 +103,13 @@ public static void ShutUpCompiler()
103103
}
104104

105105

106-
public class TestEventArgs : EventArgs
106+
public class EventArgsTest : EventArgs
107107
{
108108
public int value;
109109

110-
public TestEventArgs(int v)
110+
public EventArgsTest(int v)
111111
{
112112
this.value = v;
113113
}
114114
}
115-
}
115+
}

src/testing/exceptiontest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ public string GetExtraInfo()
9999
return extra;
100100
}
101101
}
102-
}
102+
}

src/testing/fieldtest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
3-
41
namespace Python.Test
52
{
63
//========================================================================
@@ -54,4 +51,4 @@ public void Shutup()
5451
public object ObjectField;
5552
public ISpam SpamField;
5653
}
57-
}
54+
}

src/testing/generictest.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using System.Collections;
3-
41
namespace Python.Test
52
{
63
//========================================================================
@@ -131,4 +128,4 @@ public static string Overloaded<Q>(int arg1, int arg2, string arg3)
131128
return arg3;
132129
}
133130
}
134-
}
131+
}

src/testing/globaltest.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
using System;
2-
31
//========================================================================
42
// Supports units tests for access to types without a namespace.
53
//========================================================================
64

75
public class NoNamespaceType
86
{
9-
}
7+
}

src/testing/indexertest.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections;
32

43
namespace Python.Test
@@ -415,4 +414,4 @@ public MultiDefaultKeyIndexerTest() : base()
415414
}
416415
}
417416
}
418-
}
417+
}

src/testing/interfacetest.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
31
namespace Python.Test
42
{
53
//========================================================================
@@ -62,4 +60,4 @@ private interface IPrivate
6260
{
6361
}
6462
}
65-
}
63+
}

0 commit comments

Comments
 (0)