| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ addons: | |||
| 25 | 25 | - nunit-console | |
| 26 | 26 | ||
| 27 | 27 | install: | |
| 28 | - - pip install pycparser coverage codecov six | ||
| 28 | + - pip install pycparser coverage codecov | ||
| 29 | 29 | - coverage run setup.py build_ext --inplace | |
| 30 | 30 | ||
| 31 | 31 | script: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,7 +46,7 @@ init: | |||
| 46 | 46 | ||
| 47 | 47 | install: | |
| 48 | 48 | # install for wheels & coverage | |
| 49 | - - pip install --upgrade pip wheel coverage codecov six | ||
| 49 | + - pip install --upgrade pip wheel coverage codecov | ||
| 50 | 50 | ||
| 51 | 51 | # Install OpenCover. Can't put on packages.config; not Linux/Mono compatible | |
| 52 | 52 | - .\tools\nuget\nuget.exe install OpenCover -OutputDirectory packages | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,7 @@ | |||
| 3 | 3 | import unittest | |
| 4 | 4 | import Python.Test as Test | |
| 5 | 5 | import System | |
| 6 | - import six | ||
| 7 | - | ||
| 8 | - if six.PY3: | ||
| 9 | - long = int | ||
| 10 | - unichr = chr | ||
| 6 | + from _compat import UserList, PY2, long, unichr | ||
| 11 | 7 | ||
| 12 | 8 | ||
| 13 | 9 | class ArrayTests(unittest.TestCase): | |
@@ -1098,10 +1094,6 @@ def testSequenceArrayConversion(self): | |||
| 1098 | 1094 | """Test conversion of sequence-like objects to array arguments.""" | |
| 1099 | 1095 | from Python.Test import ArrayConversionTest | |
| 1100 | 1096 | from Python.Test import Spam | |
| 1101 | - if six.PY3: | ||
| 1102 | - from collections import UserList | ||
| 1103 | - else: | ||
| 1104 | - from UserList import UserList | ||
| 1105 | 1097 | ||
| 1106 | 1098 | items = UserList() | |
| 1107 | 1099 | for i in range(10): | |
@@ -1115,10 +1107,6 @@ def testSequenceNestedArrayConversion(self): | |||
| 1115 | 1107 | """Test conversion of sequences to array-of-array arguments.""" | |
| 1116 | 1108 | from Python.Test import ArrayConversionTest | |
| 1117 | 1109 | from Python.Test import Spam | |
| 1118 | - if six.PY3: | ||
| 1119 | - from collections import UserList | ||
| 1120 | - else: | ||
| 1121 | - from UserList import UserList | ||
| 1122 | 1110 | ||
| 1123 | 1111 | items = UserList() | |
| 1124 | 1112 | for i in range(10): | |
@@ -1204,10 +1192,6 @@ def testSequenceArrayConversionTypeChecking(self): | |||
| 1204 | 1192 | """Test error handling for sequence conversion to array arguments.""" | |
| 1205 | 1193 | from Python.Test import ArrayConversionTest | |
| 1206 | 1194 | from Python.Test import Spam | |
| 1207 | - if six.PY3: | ||
| 1208 | - from collections import UserList | ||
| 1209 | - else: | ||
| 1210 | - from UserList import UserList | ||
| 1211 | 1195 | ||
| 1212 | 1196 | # This should work, because null / None is a valid value in an | |
| 1213 | 1197 | # array of reference types. | |
@@ -1322,9 +1306,9 @@ def testSpecialArrayCreation(self): | |||
| 1322 | 1306 | self.assertTrue(value[1] == 127) | |
| 1323 | 1307 | self.assertTrue(value.Length == 2) | |
| 1324 | 1308 | ||
| 1325 | - value = Array[System.Char]([six.u('A'), six.u('Z')]) | ||
| 1326 | - self.assertTrue(value[0] == six.u('A')) | ||
| 1327 | - self.assertTrue(value[1] == six.u('Z')) | ||
| 1309 | + value = Array[System.Char]([u'A', u'Z']) | ||
| 1310 | + self.assertTrue(value[0] == u'A') | ||
| 1311 | + self.assertTrue(value[1] == u'Z') | ||
| 1328 | 1312 | self.assertTrue(value.Length == 2) | |
| 1329 | 1313 | ||
| 1330 | 1314 | value = Array[System.Char]([0, 65535]) | |
@@ -1353,7 +1337,7 @@ def testSpecialArrayCreation(self): | |||
| 1353 | 1337 | self.assertTrue(value.Length == 2) | |
| 1354 | 1338 | ||
| 1355 | 1339 | # there's no explicit long type in python3, use System.Int64 instead | |
| 1356 | - if not six.PY3: | ||
| 1340 | + if PY2: | ||
| 1357 | 1341 | value = Array[long]([0, long(9223372036854775807)]) | |
| 1358 | 1342 | self.assertTrue(value[0] == 0) | |
| 1359 | 1343 | self.assertTrue(value[1] == long(9223372036854775807)) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,18 +1,13 @@ | |||
| 1 | 1 | # -*- coding: utf-8 -*- | |
| 2 | 2 | ||
| 3 | - import types | ||
| 4 | 3 | import unittest | |
| 5 | 4 | ||
| 6 | 5 | import Python.Test as Test | |
| 7 | 6 | import System | |
| 8 | - import six | ||
| 9 | 7 | from Python.Test import ClassTest | |
| 10 | 8 | from System.Collections import Hashtable | |
| 11 | 9 | ||
| 12 | - if six.PY3: | ||
| 13 | - DictProxyType = type(object.__dict__) | ||
| 14 | - else: | ||
| 15 | - DictProxyType = types.DictProxyType | ||
| 10 | + from _compat import DictProxyType | ||
| 16 | 11 | ||
| 17 | 12 | ||
| 18 | 13 | class ClassTests(unittest.TestCase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,12 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | 3 | import unittest | |
| 4 | 4 | import types | |
| 5 | - import six | ||
| 6 | - | ||
| 7 | - if six.PY3: | ||
| 8 | - ClassType = type | ||
| 9 | - else: | ||
| 10 | - ClassType = types.ClassType | ||
| 5 | + from _compat import PY2, PY3, ClassType | ||
| 11 | 6 | ||
| 12 | 7 | ||
| 13 | 8 | class CompatibilityTests(unittest.TestCase): | |
@@ -19,10 +14,11 @@ def isCLRModule(self, object): | |||
| 19 | 14 | return type(object).__name__ == 'ModuleObject' | |
| 20 | 15 | ||
| 21 | 16 | def isCLRRootModule(self, object): | |
| 22 | - if six.PY3: | ||
| 17 | + if PY3: | ||
| 23 | 18 | # in Python 3 the clr module is a normal python module | |
| 24 | 19 | return object.__name__ == "clr" | |
| 25 | - return type(object).__name__ == 'CLRModule' | ||
| 20 | + elif PY2: | ||
| 21 | + return type(object).__name__ == 'CLRModule' | ||
| 26 | 22 | ||
| 27 | 23 | def isCLRClass(self, object): | |
| 28 | 24 | return type(object).__name__ == 'CLR Metatype' # for now | |
@@ -39,12 +35,12 @@ def testSimpleImport(self): | |||
| 39 | 35 | self.assertTrue(type(sys) == types.ModuleType) | |
| 40 | 36 | self.assertTrue(sys.__name__ == 'sys') | |
| 41 | 37 | ||
| 42 | - if six.PY3: | ||
| 38 | + if PY3: | ||
| 43 | 39 | import http.client | |
| 44 | 40 | self.assertTrue(type(http.client) == types.ModuleType) | |
| 45 | 41 | self.assertTrue(http.client.__name__ == 'http.client') | |
| 46 | 42 | ||
| 47 | - else: | ||
| 43 | + elif PY2: | ||
| 48 | 44 | import httplib | |
| 49 | 45 | self.assertTrue(type(httplib) == types.ModuleType) | |
| 50 | 46 | self.assertTrue(httplib.__name__ == 'httplib') | |
@@ -59,12 +55,12 @@ def testSimpleImportWithAlias(self): | |||
| 59 | 55 | self.assertTrue(type(mySys) == types.ModuleType) | |
| 60 | 56 | self.assertTrue(mySys.__name__ == 'sys') | |
| 61 | 57 | ||
| 62 | - if six.PY3: | ||
| 58 | + if PY3: | ||
| 63 | 59 | import http.client as myHttplib | |
| 64 | 60 | self.assertTrue(type(myHttplib) == types.ModuleType) | |
| 65 | 61 | self.assertTrue(myHttplib.__name__ == 'http.client') | |
| 66 | 62 | ||
| 67 | - else: | ||
| 63 | + elif PY2: | ||
| 68 | 64 | import httplib as myHttplib | |
| 69 | 65 | self.assertTrue(type(myHttplib) == types.ModuleType) | |
| 70 | 66 | self.assertTrue(myHttplib.__name__ == 'httplib') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,11 +3,7 @@ | |||
| 3 | 3 | import unittest | |
| 4 | 4 | from Python.Test import ConversionTest | |
| 5 | 5 | import System | |
| 6 | - import six | ||
| 7 | - | ||
| 8 | - if six.PY3: | ||
| 9 | - long = int | ||
| 10 | - unichr = chr | ||
| 6 | + from _compat import indexbytes, long, unichr | ||
| 11 | 7 | ||
| 12 | 8 | ||
| 13 | 9 | class ConversionTests(unittest.TestCase): | |
@@ -171,16 +167,16 @@ def testCharConversion(self): | |||
| 171 | 167 | self.assertTrue(System.Char.MinValue == unichr(0)) | |
| 172 | 168 | ||
| 173 | 169 | object = ConversionTest() | |
| 174 | - self.assertTrue(object.CharField == six.u('A')) | ||
| 170 | + self.assertTrue(object.CharField == u'A') | ||
| 175 | 171 | ||
| 176 | 172 | object.CharField = 'B' | |
| 177 | - self.assertTrue(object.CharField == six.u('B')) | ||
| 173 | + self.assertTrue(object.CharField == u'B') | ||
| 178 | 174 | ||
| 179 | - object.CharField = six.u('B') | ||
| 180 | - self.assertTrue(object.CharField == six.u('B')) | ||
| 175 | + object.CharField = u'B' | ||
| 176 | + self.assertTrue(object.CharField == u'B') | ||
| 181 | 177 | ||
| 182 | 178 | object.CharField = 67 | |
| 183 | - self.assertTrue(object.CharField == six.u('C')) | ||
| 179 | + self.assertTrue(object.CharField == u'C') | ||
| 184 | 180 | ||
| 185 | 181 | def test(): | |
| 186 | 182 | ConversionTest().CharField = 65536 | |
@@ -644,25 +640,25 @@ def testStringConversion(self): | |||
| 644 | 640 | object = ConversionTest() | |
| 645 | 641 | ||
| 646 | 642 | self.assertTrue(object.StringField == "spam") | |
| 647 | - self.assertTrue(object.StringField == six.u("spam")) | ||
| 643 | + self.assertTrue(object.StringField == u"spam") | ||
| 648 | 644 | ||
| 649 | 645 | object.StringField = "eggs" | |
| 650 | 646 | self.assertTrue(object.StringField == "eggs") | |
| 651 | - self.assertTrue(object.StringField == six.u("eggs")) | ||
| 647 | + self.assertTrue(object.StringField == u"eggs") | ||
| 652 | 648 | ||
| 653 | - object.StringField = six.u("spam") | ||
| 649 | + object.StringField = u"spam" | ||
| 654 | 650 | self.assertTrue(object.StringField == "spam") | |
| 655 | - self.assertTrue(object.StringField == six.u("spam")) | ||
| 651 | + self.assertTrue(object.StringField == u"spam") | ||
| 656 | 652 | ||
| 657 | - object.StringField = six.u('\uffff\uffff') | ||
| 658 | - self.assertTrue(object.StringField == six.u('\uffff\uffff')) | ||
| 653 | + object.StringField = u'\uffff\uffff' | ||
| 654 | + self.assertTrue(object.StringField == u'\uffff\uffff') | ||
| 659 | 655 | ||
| 660 | 656 | object.StringField = System.String("spam") | |
| 661 | 657 | self.assertTrue(object.StringField == "spam") | |
| 662 | - self.assertTrue(object.StringField == six.u("spam")) | ||
| 658 | + self.assertTrue(object.StringField == u"spam") | ||
| 663 | 659 | ||
| 664 | - object.StringField = System.String(six.u('\uffff\uffff')) | ||
| 665 | - self.assertTrue(object.StringField == six.u('\uffff\uffff')) | ||
| 660 | + object.StringField = System.String(u'\uffff\uffff') | ||
| 661 | + self.assertTrue(object.StringField == u'\uffff\uffff') | ||
| 666 | 662 | ||
| 667 | 663 | object.StringField = None | |
| 668 | 664 | self.assertTrue(object.StringField == None) | |
@@ -809,11 +805,11 @@ def testByteArrayConversion(self): | |||
| 809 | 805 | self.assertTrue(array[0] == 0) | |
| 810 | 806 | self.assertTrue(array[4] == 4) | |
| 811 | 807 | ||
| 812 | - value = six.b("testing") | ||
| 808 | + value = b"testing" | ||
| 813 | 809 | object.ByteArrayField = value | |
| 814 | 810 | array = object.ByteArrayField | |
| 815 | 811 | for i in range(len(value)): | |
| 816 | - self.assertTrue(array[i] == six.indexbytes(value, i)) | ||
| 812 | + self.assertTrue(array[i] == indexbytes(value, i)) | ||
| 817 | 813 | ||
| 818 | 814 | def testSByteArrayConversion(self): | |
| 819 | 815 | """Test sbyte array conversion.""" | |
@@ -827,11 +823,11 @@ def testSByteArrayConversion(self): | |||
| 827 | 823 | self.assertTrue(array[0] == 0) | |
| 828 | 824 | self.assertTrue(array[4] == 4) | |
| 829 | 825 | ||
| 830 | - value = six.b("testing") | ||
| 826 | + value = b"testing" | ||
| 831 | 827 | object.SByteArrayField = value | |
| 832 | 828 | array = object.SByteArrayField | |
| 833 | 829 | for i in range(len(value)): | |
| 834 | - self.assertTrue(array[i] == six.indexbytes(value, i)) | ||
| 830 | + self.assertTrue(array[i] == indexbytes(value, i)) | ||
| 835 | 831 | ||
| 836 | 832 | ||
| 837 | 833 | def test_suite(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,15 +4,9 @@ | |||
| 4 | 4 | from Python.Test import StringDelegate, ObjectDelegate | |
| 5 | 5 | from Python.Test import BoolDelegate | |
| 6 | 6 | import unittest | |
| 7 | - import types | ||
| 8 | 7 | import Python.Test as Test | |
| 9 | 8 | import System | |
| 10 | - import six | ||
| 11 | - | ||
| 12 | - if six.PY3: | ||
| 13 | - DictProxyType = type(object.__dict__) | ||
| 14 | - else: | ||
| 15 | - DictProxyType = types.DictProxyType | ||
| 9 | + from _compat import DictProxyType | ||
| 16 | 10 | ||
| 17 | 11 | ||
| 18 | 12 | class DelegateTests(unittest.TestCase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,9 @@ | |||
| 1 | 1 | # -*- coding: utf-8 -*- | |
| 2 | 2 | ||
| 3 | 3 | import unittest | |
| 4 | - import types | ||
| 5 | 4 | from System import DayOfWeek | |
| 6 | 5 | from Python import Test | |
| 7 | - import six | ||
| 8 | - | ||
| 9 | - if six.PY3: | ||
| 10 | - DictProxyType = type(object.__dict__) | ||
| 11 | - long = int | ||
| 12 | - else: | ||
| 13 | - DictProxyType = types.DictProxyType | ||
| 6 | + from _compat import DictProxyType, long | ||
| 14 | 7 | ||
| 15 | 8 | ||
| 16 | 9 | class EnumTests(unittest.TestCase): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,10 +3,7 @@ | |||
| 3 | 3 | import sys | |
| 4 | 4 | import unittest | |
| 5 | 5 | import System | |
| 6 | - import six | ||
| 7 | - | ||
| 8 | - if six.PY3: | ||
| 9 | - unicode = str | ||
| 6 | + from _compat import PY2, PY3, pickle, text_type | ||
| 10 | 7 | ||
| 11 | 8 | ||
| 12 | 9 | class ExceptionTests(unittest.TestCase): | |
@@ -17,7 +14,7 @@ def testUnifiedExceptionSemantics(self): | |||
| 17 | 14 | from System import Exception, Object | |
| 18 | 15 | ||
| 19 | 16 | e = Exception('Something bad happened') | |
| 20 | - if not six.PY3: | ||
| 17 | + if PY2: | ||
| 21 | 18 | import exceptions | |
| 22 | 19 | self.assertTrue(isinstance(e, exceptions.Exception)) | |
| 23 | 20 | self.assertTrue(isinstance(e, Exception)) | |
@@ -212,9 +209,9 @@ def testCatchExceptionManagedClass(self): | |||
| 212 | 209 | def testCatchExceptionPythonClass(self): | |
| 213 | 210 | """Test catching the python class of an exception.""" | |
| 214 | 211 | from System import OverflowException | |
| 215 | - if six.PY3: | ||
| 212 | + if PY3: | ||
| 216 | 213 | from builtins import Exception | |
| 217 | - else: | ||
| 214 | + elif PY2: | ||
| 218 | 215 | from exceptions import Exception | |
| 219 | 216 | ||
| 220 | 217 | try: | |
@@ -288,8 +285,8 @@ def testStrOfException(self): | |||
| 288 | 285 | Convert.ToDateTime('this will fail') | |
| 289 | 286 | except FormatException: | |
| 290 | 287 | e = sys.exc_info()[1] | |
| 291 | - msg = unicode(e).encode("utf8") # fix for international installation | ||
| 292 | - self.assertTrue(msg.find(unicode('System.Convert.ToDateTime').encode("utf8")) > -1, msg) | ||
| 288 | + msg = text_type(e).encode("utf8") # fix for international installation | ||
| 289 | + self.assertTrue(msg.find(text_type('System.Convert.ToDateTime').encode("utf8")) > -1, msg) | ||
| 293 | 290 | ||
| 294 | 291 | def testPythonCompatOfManagedExceptions(self): | |
| 295 | 292 | """Test if managed exceptions are compatible with Python's implementation | |
@@ -299,14 +296,14 @@ def testPythonCompatOfManagedExceptions(self): | |||
| 299 | 296 | ||
| 300 | 297 | e = OverflowException(msg) | |
| 301 | 298 | self.assertEqual(str(e), msg) | |
| 302 | - self.assertEqual(unicode(e), msg) | ||
| 299 | + self.assertEqual(text_type(e), msg) | ||
| 303 | 300 | ||
| 304 | 301 | self.assertEqual(e.args, (msg,)) | |
| 305 | 302 | self.assertTrue(isinstance(e.args, tuple)) | |
| 306 | - if six.PY2: | ||
| 307 | - self.assertEqual(repr(e), "OverflowException(u'A simple message',)") | ||
| 308 | - else: | ||
| 303 | + if PY3: | ||
| 309 | 304 | self.assertEqual(repr(e), "OverflowException('A simple message',)") | |
| 305 | + elif PY2: | ||
| 306 | + self.assertEqual(repr(e), "OverflowException(u'A simple message',)") | ||
| 310 | 307 | ||
| 311 | 308 | def testExceptionIsInstanceOfSystemObject(self): | |
| 312 | 309 | """Test behavior of isinstance(<managed exception>, System.Object).""" | |
@@ -337,10 +334,6 @@ def testExceptionIsInstanceOfSystemObject(self): | |||
| 337 | 334 | ||
| 338 | 335 | def testPicklingExceptions(self): | |
| 339 | 336 | from System import Exception | |
| 340 | - try: | ||
| 341 | - import cPickle as pickle | ||
| 342 | - except ImportError: | ||
| 343 | - import pickle | ||
| 344 | 337 | ||
| 345 | 338 | exc = Exception("test") | |
| 346 | 339 | dumped = pickle.dumps(exc) | |
@@ -349,7 +342,8 @@ def testPicklingExceptions(self): | |||
| 349 | 342 | self.assertEqual(exc.args, loaded.args) | |
| 350 | 343 | ||
| 351 | 344 | def testChainedExceptions(self): | |
| 352 | - if six.PY3: | ||
| 345 | + # TODO: Why is this test PY3 only? | ||
| 346 | + if PY3: | ||
| 353 | 347 | from Python.Test import ExceptionTest | |
| 354 | 348 | ||
| 355 | 349 | try: | |
@@ -358,7 +352,7 @@ def testChainedExceptions(self): | |||
| 358 | 352 | msgs = [ | |
| 359 | 353 | "Outer exception", | |
| 360 | 354 | "Inner exception", | |
| 361 | - "Innermost exception" | ||
| 355 | + "Innermost exception", | ||
| 362 | 356 | ] | |
| 363 | 357 | ||
| 364 | 358 | for msg in msgs: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments