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

Skip to content

Commit e73e7c1

Browse files
committed
Drop some obsolete comments and reenable some tests
1 parent 61691a5 commit e73e7c1

8 files changed

Lines changed: 13 additions & 48 deletions

File tree

src/embed_tests/Dynamic.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,9 @@ public void AssignNone()
4545
/// Check whether we can get the attr of a python object when the
4646
/// value of attr is a PyObject.
4747
/// </summary>
48-
/// <remarks>
49-
/// FIXME: Issue on Travis PY27: Error : Python.EmbeddingTest.dynamicTest.AssignPyObject
50-
/// Python.Runtime.PythonException : ImportError : /home/travis/virtualenv/python2.7.9/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyLong_AsInt
51-
/// </remarks>
5248
[Test]
5349
public void AssignPyObject()
5450
{
55-
if (Environment.GetEnvironmentVariable("TRAVIS") == "true" &&
56-
Environment.GetEnvironmentVariable("TRAVIS_PYTHON_VERSION") == "2.7")
57-
{
58-
Assert.Ignore("Fails on Travis/PY27: ImportError: ... undefined symbol: _PyLong_AsInt");
59-
}
60-
6151
dynamic sys = Py.Import("sys");
6252
dynamic io = Py.Import("io");
6353
sys.testattr = io.StringIO();

src/embed_tests/TestPyString.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public void TestEmptyStringCtor()
2323
}
2424

2525
[Test]
26-
[Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")]
2726
public void TestPyObjectCtor()
2827
{
2928
const string expected = "Foo";
@@ -58,7 +57,6 @@ public void TestCtorBorrowed()
5857
}
5958

6059
[Test]
61-
[Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")]
6260
public void IsStringTrue()
6361
{
6462
var t = new PyString("foo");

src/embed_tests/TestPyTuple.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ public void TestPyTupleCtorArray()
8181
/// Test has second purpose. Currently it generated an Exception
8282
/// that the GC failed to remove often and caused AppDomain unload
8383
/// errors at the end of tests. See GH#397 for more info.
84-
/// <para />
85-
/// Curious, on PY27 it gets a Unicode on the ex.Message. On PY3+ its string.
8684
/// </remarks>
8785
[Test]
8886
public void TestPyTupleInvalidAppend()

src/runtime/Native/CustomMarshaler.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public static ICustomMarshaler GetInstance(string cookie)
7272
return Instance;
7373
}
7474

75-
public static string? PtrToStringUni(IntPtr p)
75+
public static string? PtrToString(IntPtr p)
7676
{
7777
if (p == IntPtr.Zero)
7878
{
@@ -106,36 +106,19 @@ public static int GetUnicodeByteLength(IntPtr p)
106106
}
107107

108108
/// <summary>
109-
/// Utility function for Marshaling Unicode on PY3 and AnsiStr on PY2.
110-
/// Use on functions whose Input signatures changed between PY2/PY3.
111-
/// Ex. Py_SetPythonHome
109+
/// Utility function for Marshaling Unicode
112110
/// </summary>
113111
/// <param name="s">Managed String</param>
114112
/// <returns>
115-
/// Ptr to Native String ANSI(PY2)/Unicode(PY3/UCS2)/UTF32(PY3/UCS4.
113+
/// Ptr to Native String
116114
/// </returns>
117115
/// <remarks>
118116
/// You MUST deallocate the IntPtr of the Return when done with it.
119117
/// </remarks>
120-
public static IntPtr Py3UnicodePy2StringtoPtr(string s)
118+
public static IntPtr StringToPtr(string s)
121119
{
122120
return Instance.MarshalManagedToNative(s);
123121
}
124-
125-
/// <summary>
126-
/// Utility function for Marshaling Unicode IntPtr on PY3 and
127-
/// AnsiStr IntPtr on PY2 to Managed Strings. Use on Python functions
128-
/// whose return type changed between PY2/PY3.
129-
/// Ex. Py_GetPythonHome
130-
/// </summary>
131-
/// <param name="p">Native Ansi/Unicode/UTF32 String</param>
132-
/// <returns>
133-
/// Managed String
134-
/// </returns>
135-
public static string? PtrToPy3UnicodePy2String(IntPtr p)
136-
{
137-
return PtrToStringUni(p);
138-
}
139122
}
140123

141124

src/runtime/PythonEngine.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ public static string ProgramName
8888
get
8989
{
9090
IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetProgramName());
91-
return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? "";
91+
return UcsMarshaler.PtrToString(p) ?? "";
9292
}
9393
set
9494
{
9595
Marshal.FreeHGlobal(_programName);
9696
_programName = Runtime.TryUsingDll(
97-
() => UcsMarshaler.Py3UnicodePy2StringtoPtr(value)
97+
() => UcsMarshaler.StringToPtr(value)
9898
);
9999
Runtime.Py_SetProgramName(_programName);
100100
}
@@ -106,13 +106,13 @@ public static string PythonHome
106106
{
107107
EnsureInitialized();
108108
IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetPythonHome());
109-
return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? "";
109+
return UcsMarshaler.PtrToString(p) ?? "";
110110
}
111111
set
112112
{
113113
// this value is null in the beginning
114114
Marshal.FreeHGlobal(_pythonHome);
115-
_pythonHome = UcsMarshaler.Py3UnicodePy2StringtoPtr(value);
115+
_pythonHome = UcsMarshaler.StringToPtr(value);
116116
Runtime.TryUsingDll(() => Runtime.Py_SetPythonHome(_pythonHome));
117117
}
118118
}
@@ -122,13 +122,13 @@ public static string PythonPath
122122
get
123123
{
124124
IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetPath());
125-
return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? "";
125+
return UcsMarshaler.PtrToString(p) ?? "";
126126
}
127127
set
128128
{
129129
Marshal.FreeHGlobal(_pythonPath);
130130
_pythonPath = Runtime.TryUsingDll(
131-
() => UcsMarshaler.Py3UnicodePy2StringtoPtr(value)
131+
() => UcsMarshaler.StringToPtr(value)
132132
);
133133
Runtime.Py_SetPath(_pythonPath);
134134
}

tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
# TODO: move tests one out of src to project root.
3-
# TODO: travis has numpy on their workers. Maybe add tests?
42

53
"""Helpers for testing."""
64

tests/test_array.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ def test_array_contains():
120120
assert 3 in items
121121
assert 4 in items
122122

123-
assert not (5 in items) # "H:\Python27\Lib\unittest\case.py", line 592, in deprecated_func,
124-
assert not (-1 in items) # TypeError: int() argument must be a string or a number, not 'NoneType'
125-
assert not (None in items) # which threw ^ here which is a little odd.
126-
# But when run from runtests.py. Not when this module ran by itself.
123+
assert not (5 in items)
124+
assert not (-1 in items)
125+
assert not (None in items)
127126

128127

129128
def test_boolean_array():

tests/test_field.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ def test_field_descriptor_abuse():
190190

191191
def test_boolean_field():
192192
"""Test boolean fields."""
193-
# change this to true / false later for Python 2.3?
194193
ob = FieldTest()
195194
assert ob.BooleanField is False
196195

0 commit comments

Comments
 (0)