| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 43de985 commit 402bfcf
36 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,65 @@ | |||
| 1 | + # -*- coding: utf-8 -*- | ||
| 2 | + | ||
| 3 | + """Python 2.7, 3.3+ compatibility module. | ||
| 4 | + | ||
| 5 | + Using Python 3 syntax to encourage upgrade unless otherwise noted. | ||
| 6 | + """ | ||
| 7 | + | ||
| 8 | + import operator | ||
| 9 | + import sys | ||
| 10 | + import types | ||
| 11 | + | ||
| 12 | + PY2 = sys.version_info[0] == 2 | ||
| 13 | + PY3 = sys.version_info[0] == 3 | ||
| 14 | + | ||
| 15 | + if PY3: | ||
| 16 | + import _thread as thread # Using PY2 name | ||
| 17 | + import pickle | ||
| 18 | + from collections import UserList | ||
| 19 | + | ||
| 20 | + indexbytes = operator.getitem | ||
| 21 | + input = input | ||
| 22 | + | ||
| 23 | + string_types = str, | ||
| 24 | + binary_type = bytes | ||
| 25 | + text_type = str | ||
| 26 | + | ||
| 27 | + DictProxyType = type(object.__dict__) | ||
| 28 | + ClassType = type | ||
| 29 | + | ||
| 30 | + # No PY3 equivalents, use PY2 name | ||
| 31 | + long = int | ||
| 32 | + unichr = chr | ||
| 33 | + unicode = str | ||
| 34 | + | ||
| 35 | + # from nowhere import Nothing | ||
| 36 | + cmp = lambda a, b: (a > b) - (a < b) # No Py3 equivalent | ||
| 37 | + map = map | ||
| 38 | + range = range | ||
| 39 | + zip = zip | ||
| 40 | + | ||
| 41 | + elif PY2: | ||
| 42 | + import thread # Using PY2 name | ||
| 43 | + import cPickle as pickle | ||
| 44 | + from UserList import UserList | ||
| 45 | + | ||
| 46 | + indexbytes = lambda buf, i: ord(buf[i]) | ||
| 47 | + input = raw_input | ||
| 48 | + | ||
| 49 | + string_types = str, unicode | ||
| 50 | + bytes_type = str | ||
| 51 | + text_type = unicode | ||
| 52 | + | ||
| 53 | + DictProxyType = types.DictProxyType | ||
| 54 | + ClassType = types.ClassType | ||
| 55 | + | ||
| 56 | + # No PY3 equivalents, use PY2 name | ||
| 57 | + long = long | ||
| 58 | + unichr = unichr | ||
| 59 | + unicode = unicode | ||
| 60 | + | ||
| 61 | + from itertools import izip, imap | ||
| 62 | + cmp = cmp | ||
| 63 | + map = imap | ||
| 64 | + range = xrange | ||
| 65 | + zip = izip | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,9 +1,18 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + # FIXME: TypeError: 'EventBinding' object is not callable | ||
| 4 | + | ||
| 1 | 5 | from __future__ import print_function | |
| 2 | - import System | ||
| 6 | + | ||
| 7 | + import clr | ||
| 3 | 8 | import gc | |
| 4 | 9 | ||
| 10 | + import System | ||
| 11 | + | ||
| 12 | + from _compat import range | ||
| 13 | + | ||
| 5 | 14 | ||
| 6 | - class LeakTest: | ||
| 15 | + class LeakTest(object): | ||
| 7 | 16 | """A leak-check test for the objects implemented in the managed | |
| 8 | 17 | runtime. For each kind of object tested, memory should reach | |
| 9 | 18 | a particular level after warming up and stay essentially the | |
@@ -54,7 +63,7 @@ def report(self): | |||
| 54 | 63 | def testModules(self): | |
| 55 | 64 | self.notify("Running module leak check...") | |
| 56 | 65 | ||
| 57 | - for i in xrange(self.count): | ||
| 66 | + for i in range(self.count): | ||
| 58 | 67 | if i == 10: | |
| 59 | 68 | self.start_test() | |
| 60 | 69 | ||
@@ -73,7 +82,7 @@ def testClasses(self): | |||
| 73 | 82 | ||
| 74 | 83 | self.notify("Running class leak check...") | |
| 75 | 84 | ||
| 76 | - for i in xrange(self.count): | ||
| 85 | + for i in range(self.count): | ||
| 77 | 86 | if i == 10: | |
| 78 | 87 | self.start_test() | |
| 79 | 88 | ||
@@ -86,7 +95,7 @@ def testClasses(self): | |||
| 86 | 95 | del x | |
| 87 | 96 | ||
| 88 | 97 | # Delegate type | |
| 89 | - x = StringDelegate(hello) | ||
| 98 | + x = StringDelegate(hello_func) | ||
| 90 | 99 | del x | |
| 91 | 100 | ||
| 92 | 101 | self.end_test() | |
@@ -96,7 +105,7 @@ def testEnumerations(self): | |||
| 96 | 105 | ||
| 97 | 106 | self.notify("Running enum leak check...") | |
| 98 | 107 | ||
| 99 | - for i in xrange(self.count): | ||
| 108 | + for i in range(self.count): | ||
| 100 | 109 | if i == 10: | |
| 101 | 110 | self.start_test() | |
| 102 | 111 | ||
@@ -131,7 +140,7 @@ def testEvents(self): | |||
| 131 | 140 | ||
| 132 | 141 | self.notify("Running event leak check...") | |
| 133 | 142 | ||
| 134 | - for i in xrange(self.count): | ||
| 143 | + for i in range(self.count): | ||
| 135 | 144 | if i == 10: | |
| 136 | 145 | self.start_test() | |
| 137 | 146 | ||
@@ -210,13 +219,13 @@ def testDelegates(self): | |||
| 210 | 219 | ||
| 211 | 220 | self.notify("Running delegate leak check...") | |
| 212 | 221 | ||
| 213 | - for i in xrange(self.count): | ||
| 222 | + for i in range(self.count): | ||
| 214 | 223 | if i == 10: | |
| 215 | 224 | self.start_test() | |
| 216 | 225 | ||
| 217 | 226 | # Delegate from function | |
| 218 | 227 | testob = DelegateTest() | |
| 219 | - d = StringDelegate(hello) | ||
| 228 | + d = StringDelegate(hello_func) | ||
| 220 | 229 | testob.CallStringDelegate(d) | |
| 221 | 230 | testob.stringDelegate = d | |
| 222 | 231 | testob.stringDelegate() | |
@@ -225,7 +234,7 @@ def testDelegates(self): | |||
| 225 | 234 | del d | |
| 226 | 235 | ||
| 227 | 236 | # Delegate from instance method | |
| 228 | - inst = Hello() | ||
| 237 | + inst = HelloClass() | ||
| 229 | 238 | testob = DelegateTest() | |
| 230 | 239 | d = StringDelegate(inst.hello) | |
| 231 | 240 | testob.CallStringDelegate(d) | |
@@ -238,7 +247,7 @@ def testDelegates(self): | |||
| 238 | 247 | ||
| 239 | 248 | # Delegate from static method | |
| 240 | 249 | testob = DelegateTest() | |
| 241 | - d = StringDelegate(Hello.s_hello) | ||
| 250 | + d = StringDelegate(HelloClass.s_hello) | ||
| 242 | 251 | testob.CallStringDelegate(d) | |
| 243 | 252 | testob.stringDelegate = d | |
| 244 | 253 | testob.stringDelegate() | |
@@ -248,7 +257,7 @@ def testDelegates(self): | |||
| 248 | 257 | ||
| 249 | 258 | # Delegate from class method | |
| 250 | 259 | testob = DelegateTest() | |
| 251 | - d = StringDelegate(Hello.c_hello) | ||
| 260 | + d = StringDelegate(HelloClass.c_hello) | ||
| 252 | 261 | testob.CallStringDelegate(d) | |
| 253 | 262 | testob.stringDelegate = d | |
| 254 | 263 | testob.stringDelegate() | |
@@ -257,7 +266,7 @@ def testDelegates(self): | |||
| 257 | 266 | del d | |
| 258 | 267 | ||
| 259 | 268 | # Delegate from callable object | |
| 260 | - inst = Hello() | ||
| 269 | + inst = HelloClass() | ||
| 261 | 270 | testob = DelegateTest() | |
| 262 | 271 | d = StringDelegate(inst) | |
| 263 | 272 | testob.CallStringDelegate(d) | |
@@ -290,7 +299,7 @@ def testDelegates(self): | |||
| 290 | 299 | ||
| 291 | 300 | # Nested delegates | |
| 292 | 301 | testob = DelegateTest() | |
| 293 | - d1 = StringDelegate(hello) | ||
| 302 | + d1 = StringDelegate(hello_func) | ||
| 294 | 303 | d2 = StringDelegate(d1) | |
| 295 | 304 | testob.CallStringDelegate(d2) | |
| 296 | 305 | testob.stringDelegate = d2 | |
@@ -302,8 +311,8 @@ def testDelegates(self): | |||
| 302 | 311 | ||
| 303 | 312 | # Multicast delegates | |
| 304 | 313 | testob = DelegateTest() | |
| 305 | - d1 = StringDelegate(hello) | ||
| 306 | - d2 = StringDelegate(hello) | ||
| 314 | + d1 = StringDelegate(hello_func) | ||
| 315 | + d2 = StringDelegate(hello_func) | ||
| 307 | 316 | md = System.Delegate.Combine(d1, d2) | |
| 308 | 317 | testob.CallStringDelegate(md) | |
| 309 | 318 | testob.stringDelegate = md | |
@@ -317,7 +326,7 @@ def testDelegates(self): | |||
| 317 | 326 | self.end_test() | |
| 318 | 327 | ||
| 319 | 328 | ||
| 320 | - class GenericHandler: | ||
| 329 | + class GenericHandler(object): | ||
| 321 | 330 | """A generic handler to test event callbacks.""" | |
| 322 | 331 | ||
| 323 | 332 | def __init__(self): | |
@@ -327,7 +336,7 @@ def handler(self, sender, args): | |||
| 327 | 336 | self.value = args.value | |
| 328 | 337 | ||
| 329 | 338 | ||
| 330 | - class VariableArgsHandler: | ||
| 339 | + class VariableArgsHandler(object): | ||
| 331 | 340 | """A variable args handler to test event callbacks.""" | |
| 332 | 341 | ||
| 333 | 342 | def __init__(self): | |
@@ -338,7 +347,7 @@ def handler(self, *args): | |||
| 338 | 347 | self.value = eventargs.value | |
| 339 | 348 | ||
| 340 | 349 | ||
| 341 | - class CallableHandler: | ||
| 350 | + class CallableHandler(object): | ||
| 342 | 351 | """A callable handler to test event callbacks.""" | |
| 343 | 352 | ||
| 344 | 353 | def __init__(self): | |
@@ -348,7 +357,7 @@ def __call__(self, sender, args): | |||
| 348 | 357 | self.value = args.value | |
| 349 | 358 | ||
| 350 | 359 | ||
| 351 | - class VarCallableHandler: | ||
| 360 | + class VarCallableHandler(object): | ||
| 352 | 361 | """A variable args callable handler to test event callbacks.""" | |
| 353 | 362 | ||
| 354 | 363 | def __init__(self): | |
@@ -381,7 +390,7 @@ def handler(cls, sender, args): | |||
| 381 | 390 | handler = classmethod(handler) | |
| 382 | 391 | ||
| 383 | 392 | ||
| 384 | - class Hello: | ||
| 393 | + class HelloClass(object): | ||
| 385 | 394 | def hello(self): | |
| 386 | 395 | return "hello" | |
| 387 | 396 | ||
@@ -399,7 +408,7 @@ def c_hello(cls): | |||
| 399 | 408 | c_hello = classmethod(c_hello) | |
| 400 | 409 | ||
| 401 | 410 | ||
| 402 | - def hello(): | ||
| 411 | + def hello_func(): | ||
| 403 | 412 | return "hello" | |
| 404 | 413 | ||
| 405 | 414 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,14 +1,25 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + # FIXME: FAIL: testImplicitAssemblyLoad AssertionError: 0 != 1 | ||
| 4 | + | ||
| 1 | 5 | """Run all of the unit tests for this package over and over, | |
| 2 | - in order to provide for better profiling.""" | ||
| 6 | + in order to provide for better profiling. | ||
| 7 | + """ | ||
| 8 | + | ||
| 3 | 9 | from __future__ import print_function | |
| 4 | 10 | ||
| 11 | + import gc | ||
| 12 | + import os | ||
| 13 | + import sys | ||
| 14 | + import time | ||
| 5 | 15 | ||
| 6 | - def main(): | ||
| 7 | - import sys, os, gc, time | ||
| 16 | + import runtests | ||
| 17 | + from _compat import range | ||
| 8 | 18 | ||
| 19 | + | ||
| 20 | + def main(): | ||
| 9 | 21 | dirname = os.path.split(__file__) | |
| 10 | 22 | sys.path.append(dirname) | |
| 11 | - import runtests | ||
| 12 | 23 | ||
| 13 | 24 | gc.set_debug(gc.DEBUG_LEAK) | |
| 14 | 25 | ||
@@ -28,4 +39,3 @@ def main(): | |||
| 28 | 39 | ||
| 29 | 40 | if __name__ == '__main__': | |
| 30 | 41 | main() | |
| 31 | - sys.exit(0) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,15 @@ | |||
| 1 | + #!/usr/bin/env python | ||
| 2 | + # -*- coding: utf-8 -*- | ||
| 3 | + | ||
| 1 | 4 | """Run all of the unit tests for this package.""" | |
| 2 | 5 | ||
| 6 | + from __future__ import print_function | ||
| 7 | + | ||
| 3 | 8 | import os | |
| 4 | 9 | import sys | |
| 5 | 10 | import unittest | |
| 6 | - import warnfilter | ||
| 7 | 11 | ||
| 8 | - warnfilter.addClrWarnfilter() | ||
| 12 | + from _compat import input | ||
| 9 | 13 | ||
| 10 | 14 | try: | |
| 11 | 15 | import System | |
@@ -14,16 +18,17 @@ | |||
| 14 | 18 | import clr | |
| 15 | 19 | ||
| 16 | 20 | test_modules = ( | |
| 17 | - 'test_module', # Passes on its own, but not here if | ||
| 21 | + # Passes on its own, but not here if | ||
| 18 | 22 | # other test modules that import System.Windows.Forms | |
| 19 | 23 | # run first. They must not do module level import/AddReference() | |
| 20 | 24 | # of the System.Windows.Forms namespace. | |
| 25 | + 'test_module', | ||
| 26 | + | ||
| 21 | 27 | 'test_suite', | |
| 22 | 28 | 'test_event', | |
| 23 | 29 | 'test_constructors', | |
| 24 | 30 | 'test_enum', | |
| 25 | 31 | 'test_method', | |
| 26 | - | ||
| 27 | 32 | 'test_exceptions', | |
| 28 | 33 | 'test_compat', | |
| 29 | 34 | 'test_generic', | |
@@ -35,11 +40,18 @@ | |||
| 35 | 40 | 'test_indexer', | |
| 36 | 41 | 'test_delegate', | |
| 37 | 42 | 'test_array', | |
| 38 | - 'test_thread' | ||
| 43 | + 'test_thread', | ||
| 44 | + 'test_docstring', | ||
| 45 | + | ||
| 46 | + # FIXME: Fails due to unhandled exception | ||
| 47 | + # 'test_engine', | ||
| 48 | + | ||
| 49 | + # FIXME: Fails in Linux | ||
| 50 | + # 'test_subclass', | ||
| 39 | 51 | ) | |
| 40 | 52 | ||
| 41 | 53 | ||
| 42 | - def removePyc(): | ||
| 54 | + def remove_pyc(): | ||
| 43 | 55 | path = os.path.dirname(os.path.abspath(__file__)) | |
| 44 | 56 | for name in test_modules: | |
| 45 | 57 | pyc = os.path.join(path, "%s.pyc" % name) | |
@@ -48,7 +60,7 @@ def removePyc(): | |||
| 48 | 60 | ||
| 49 | 61 | ||
| 50 | 62 | def main(verbosity=1): | |
| 51 | - removePyc() | ||
| 63 | + remove_pyc() | ||
| 52 | 64 | ||
| 53 | 65 | suite = unittest.TestSuite() | |
| 54 | 66 | ||
@@ -62,7 +74,7 @@ def main(verbosity=1): | |||
| 62 | 74 | ||
| 63 | 75 | ||
| 64 | 76 | if __name__ == '__main__': | |
| 65 | - main(1) | ||
| 77 | + main() | ||
| 66 | 78 | if '--pause' in sys.argv: | |
| 67 | 79 | print("Press enter to continue") | |
| 68 | - raw_input() | ||
| 80 | + input() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments