| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,19 +45,9 @@ public void AssignNone() | |||
| 45 | 45 | /// Check whether we can get the attr of a python object when the | |
| 46 | 46 | /// value of attr is a PyObject. | |
| 47 | 47 | /// </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> | ||
| 52 | 48 | [Test] | |
| 53 | 49 | public void AssignPyObject() | |
| 54 | 50 | { | |
| 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 | - | ||
| 61 | 51 | dynamic sys = Py.Import("sys"); | |
| 62 | 52 | dynamic io = Py.Import("io"); | |
| 63 | 53 | sys.testattr = io.StringIO(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,7 +23,6 @@ public void TestEmptyStringCtor() | |||
| 23 | 23 | } | |
| 24 | 24 | ||
| 25 | 25 | [Test] | |
| 26 | - [Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")] | ||
| 27 | 26 | public void TestPyObjectCtor() | |
| 28 | 27 | { | |
| 29 | 28 | const string expected = "Foo"; | |
@@ -58,7 +57,6 @@ public void TestCtorBorrowed() | |||
| 58 | 57 | } | |
| 59 | 58 | ||
| 60 | 59 | [Test] | |
| 61 | - [Ignore("Ambiguous behavior between PY2/PY3. Needs remapping")] | ||
| 62 | 60 | public void IsStringTrue() | |
| 63 | 61 | { | |
| 64 | 62 | var t = new PyString("foo"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,6 @@ public void TestPyTupleCtorArray() | |||
| 81 | 81 | /// Test has second purpose. Currently it generated an Exception | |
| 82 | 82 | /// that the GC failed to remove often and caused AppDomain unload | |
| 83 | 83 | /// 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. | ||
| 86 | 84 | /// </remarks> | |
| 87 | 85 | [Test] | |
| 88 | 86 | public void TestPyTupleInvalidAppend() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,7 +72,7 @@ public static ICustomMarshaler GetInstance(string cookie) | |||
| 72 | 72 | return Instance; | |
| 73 | 73 | } | |
| 74 | 74 | ||
| 75 | - public static string? PtrToStringUni(IntPtr p) | ||
| 75 | + public static string? PtrToString(IntPtr p) | ||
| 76 | 76 | { | |
| 77 | 77 | if (p == IntPtr.Zero) | |
| 78 | 78 | { | |
@@ -106,36 +106,19 @@ public static int GetUnicodeByteLength(IntPtr p) | |||
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | 108 | /// <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 | ||
| 112 | 110 | /// </summary> | |
| 113 | 111 | /// <param name="s">Managed String</param> | |
| 114 | 112 | /// <returns> | |
| 115 | - /// Ptr to Native String ANSI(PY2)/Unicode(PY3/UCS2)/UTF32(PY3/UCS4. | ||
| 113 | + /// Ptr to Native String | ||
| 116 | 114 | /// </returns> | |
| 117 | 115 | /// <remarks> | |
| 118 | 116 | /// You MUST deallocate the IntPtr of the Return when done with it. | |
| 119 | 117 | /// </remarks> | |
| 120 | - public static IntPtr Py3UnicodePy2StringtoPtr(string s) | ||
| 118 | + public static IntPtr StringToPtr(string s) | ||
| 121 | 119 | { | |
| 122 | 120 | return Instance.MarshalManagedToNative(s); | |
| 123 | 121 | } | |
| 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 | - } | ||
| 139 | 122 | } | |
| 140 | 123 | ||
| 141 | 124 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,13 +88,13 @@ public static string ProgramName | |||
| 88 | 88 | get | |
| 89 | 89 | { | |
| 90 | 90 | IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetProgramName()); | |
| 91 | - return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? ""; | ||
| 91 | + return UcsMarshaler.PtrToString(p) ?? ""; | ||
| 92 | 92 | } | |
| 93 | 93 | set | |
| 94 | 94 | { | |
| 95 | 95 | Marshal.FreeHGlobal(_programName); | |
| 96 | 96 | _programName = Runtime.TryUsingDll( | |
| 97 | - () => UcsMarshaler.Py3UnicodePy2StringtoPtr(value) | ||
| 97 | + () => UcsMarshaler.StringToPtr(value) | ||
| 98 | 98 | ); | |
| 99 | 99 | Runtime.Py_SetProgramName(_programName); | |
| 100 | 100 | } | |
@@ -106,13 +106,13 @@ public static string PythonHome | |||
| 106 | 106 | { | |
| 107 | 107 | EnsureInitialized(); | |
| 108 | 108 | IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetPythonHome()); | |
| 109 | - return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? ""; | ||
| 109 | + return UcsMarshaler.PtrToString(p) ?? ""; | ||
| 110 | 110 | } | |
| 111 | 111 | set | |
| 112 | 112 | { | |
| 113 | 113 | // this value is null in the beginning | |
| 114 | 114 | Marshal.FreeHGlobal(_pythonHome); | |
| 115 | - _pythonHome = UcsMarshaler.Py3UnicodePy2StringtoPtr(value); | ||
| 115 | + _pythonHome = UcsMarshaler.StringToPtr(value); | ||
| 116 | 116 | Runtime.TryUsingDll(() => Runtime.Py_SetPythonHome(_pythonHome)); | |
| 117 | 117 | } | |
| 118 | 118 | } | |
@@ -122,13 +122,13 @@ public static string PythonPath | |||
| 122 | 122 | get | |
| 123 | 123 | { | |
| 124 | 124 | IntPtr p = Runtime.TryUsingDll(() => Runtime.Py_GetPath()); | |
| 125 | - return UcsMarshaler.PtrToPy3UnicodePy2String(p) ?? ""; | ||
| 125 | + return UcsMarshaler.PtrToString(p) ?? ""; | ||
| 126 | 126 | } | |
| 127 | 127 | set | |
| 128 | 128 | { | |
| 129 | 129 | Marshal.FreeHGlobal(_pythonPath); | |
| 130 | 130 | _pythonPath = Runtime.TryUsingDll( | |
| 131 | - () => UcsMarshaler.Py3UnicodePy2StringtoPtr(value) | ||
| 131 | + () => UcsMarshaler.StringToPtr(value) | ||
| 132 | 132 | ); | |
| 133 | 133 | Runtime.Py_SetPath(_pythonPath); | |
| 134 | 134 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,4 @@ | |||
| 1 | 1 | # -*- 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? | ||
| 4 | 2 | ||
| 5 | 3 | """Helpers for testing.""" | |
| 6 | 4 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,10 +120,9 @@ def test_array_contains(): | |||
| 120 | 120 | assert 3 in items | |
| 121 | 121 | assert 4 in items | |
| 122 | 122 | ||
| 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) | ||
| 127 | 126 | ||
| 128 | 127 | ||
| 129 | 128 | def test_boolean_array(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,7 +190,6 @@ def test_field_descriptor_abuse(): | |||
| 190 | 190 | ||
| 191 | 191 | def test_boolean_field(): | |
| 192 | 192 | """Test boolean fields.""" | |
| 193 | - # change this to true / false later for Python 2.3? | ||
| 194 | 193 | ob = FieldTest() | |
| 195 | 194 | assert ob.BooleanField is False | |
| 196 | 195 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments