Cython 3.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Cython/Build/BuildExecutable.py +169 -0
- Cython/Build/Cache.py +199 -0
- Cython/Build/Cythonize.py +323 -0
- Cython/Build/Dependencies.py +1306 -0
- Cython/Build/Distutils.py +1 -0
- Cython/Build/Inline.py +463 -0
- Cython/Build/IpythonMagic.py +560 -0
- Cython/Build/SharedModule.py +76 -0
- Cython/Build/Tests/TestCyCache.py +194 -0
- Cython/Build/Tests/TestCythonizeArgsParser.py +481 -0
- Cython/Build/Tests/TestDependencies.py +133 -0
- Cython/Build/Tests/TestInline.py +177 -0
- Cython/Build/Tests/TestIpythonMagic.py +287 -0
- Cython/Build/Tests/TestRecythonize.py +212 -0
- Cython/Build/Tests/TestStripLiterals.py +155 -0
- Cython/Build/Tests/__init__.py +1 -0
- Cython/Build/__init__.py +8 -0
- Cython/CodeWriter.py +811 -0
- Cython/Compiler/AnalysedTreeTransforms.py +97 -0
- Cython/Compiler/Annotate.py +326 -0
- Cython/Compiler/AutoDocTransforms.py +320 -0
- Cython/Compiler/Buffer.py +680 -0
- Cython/Compiler/Builtin.py +934 -0
- Cython/Compiler/CmdLine.py +259 -0
- Cython/Compiler/Code.pxd +148 -0
- Cython/Compiler/Code.py +3375 -0
- Cython/Compiler/CodeGeneration.py +33 -0
- Cython/Compiler/CythonScope.py +187 -0
- Cython/Compiler/Dataclass.py +868 -0
- Cython/Compiler/DebugFlags.py +24 -0
- Cython/Compiler/Errors.py +295 -0
- Cython/Compiler/ExprNodes.py +15267 -0
- Cython/Compiler/FlowControl.pxd +97 -0
- Cython/Compiler/FlowControl.py +1455 -0
- Cython/Compiler/FusedNode.py +1002 -0
- Cython/Compiler/Future.py +16 -0
- Cython/Compiler/Interpreter.py +57 -0
- Cython/Compiler/Lexicon.py +340 -0
- Cython/Compiler/LineTable.py +114 -0
- Cython/Compiler/Main.py +853 -0
- Cython/Compiler/MatchCaseNodes.py +259 -0
- Cython/Compiler/MemoryView.py +922 -0
- Cython/Compiler/ModuleNode.py +4024 -0
- Cython/Compiler/Naming.py +374 -0
- Cython/Compiler/Nodes.py +10826 -0
- Cython/Compiler/Optimize.py +5256 -0
- Cython/Compiler/Options.py +835 -0
- Cython/Compiler/ParseTreeTransforms.pxd +77 -0
- Cython/Compiler/ParseTreeTransforms.py +4509 -0
- Cython/Compiler/Parsing.pxd +9 -0
- Cython/Compiler/Parsing.py +4789 -0
- Cython/Compiler/Pipeline.py +439 -0
- Cython/Compiler/PyrexTypes.py +5762 -0
- Cython/Compiler/Pythran.py +232 -0
- Cython/Compiler/Scanning.pxd +40 -0
- Cython/Compiler/Scanning.py +577 -0
- Cython/Compiler/StringEncoding.py +347 -0
- Cython/Compiler/Symtab.py +3080 -0
- Cython/Compiler/Tests/TestBuffer.py +105 -0
- Cython/Compiler/Tests/TestBuiltin.py +72 -0
- Cython/Compiler/Tests/TestCmdLine.py +586 -0
- Cython/Compiler/Tests/TestCode.py +86 -0
- Cython/Compiler/Tests/TestFlowControl.py +65 -0
- Cython/Compiler/Tests/TestGrammar.py +202 -0
- Cython/Compiler/Tests/TestMemView.py +71 -0
- Cython/Compiler/Tests/TestParseTreeTransforms.py +285 -0
- Cython/Compiler/Tests/TestScanning.py +134 -0
- Cython/Compiler/Tests/TestSignatureMatching.py +73 -0
- Cython/Compiler/Tests/TestStringEncoding.py +33 -0
- Cython/Compiler/Tests/TestTreeFragment.py +63 -0
- Cython/Compiler/Tests/TestTreePath.py +103 -0
- Cython/Compiler/Tests/TestTypes.py +75 -0
- Cython/Compiler/Tests/TestUtilityLoad.py +112 -0
- Cython/Compiler/Tests/TestVisitor.py +61 -0
- Cython/Compiler/Tests/Utils.py +36 -0
- Cython/Compiler/Tests/__init__.py +1 -0
- Cython/Compiler/TreeFragment.py +278 -0
- Cython/Compiler/TreePath.py +303 -0
- Cython/Compiler/TypeInference.py +584 -0
- Cython/Compiler/TypeSlots.py +1181 -0
- Cython/Compiler/UFuncs.py +311 -0
- Cython/Compiler/UtilNodes.py +389 -0
- Cython/Compiler/UtilityCode.py +344 -0
- Cython/Compiler/Version.py +8 -0
- Cython/Compiler/Visitor.pxd +53 -0
- Cython/Compiler/Visitor.py +861 -0
- Cython/Compiler/__init__.py +1 -0
- Cython/Coverage.py +448 -0
- Cython/Debugger/Cygdb.py +175 -0
- Cython/Debugger/DebugWriter.py +82 -0
- Cython/Debugger/Tests/TestLibCython.py +275 -0
- Cython/Debugger/Tests/__init__.py +1 -0
- Cython/Debugger/Tests/cfuncs.c +8 -0
- Cython/Debugger/Tests/codefile +49 -0
- Cython/Debugger/Tests/test_libcython_in_gdb.py +578 -0
- Cython/Debugger/Tests/test_libpython_in_gdb.py +90 -0
- Cython/Debugger/__init__.py +1 -0
- Cython/Debugger/libcython.py +1548 -0
- Cython/Debugger/libpython.py +2821 -0
- Cython/Debugging.py +20 -0
- Cython/Distutils/__init__.py +2 -0
- Cython/Distutils/build_ext.py +139 -0
- Cython/Distutils/extension.py +96 -0
- Cython/Distutils/old_build_ext.py +351 -0
- Cython/Includes/cpython/__init__.pxd +173 -0
- Cython/Includes/cpython/array.pxd +174 -0
- Cython/Includes/cpython/bool.pxd +37 -0
- Cython/Includes/cpython/buffer.pxd +112 -0
- Cython/Includes/cpython/bytearray.pxd +33 -0
- Cython/Includes/cpython/bytes.pxd +200 -0
- Cython/Includes/cpython/cellobject.pxd +35 -0
- Cython/Includes/cpython/ceval.pxd +8 -0
- Cython/Includes/cpython/codecs.pxd +121 -0
- Cython/Includes/cpython/complex.pxd +60 -0
- Cython/Includes/cpython/contextvars.pxd +145 -0
- Cython/Includes/cpython/conversion.pxd +36 -0
- Cython/Includes/cpython/datetime.pxd +395 -0
- Cython/Includes/cpython/descr.pxd +26 -0
- Cython/Includes/cpython/dict.pxd +187 -0
- Cython/Includes/cpython/exc.pxd +263 -0
- Cython/Includes/cpython/fileobject.pxd +57 -0
- Cython/Includes/cpython/float.pxd +47 -0
- Cython/Includes/cpython/function.pxd +65 -0
- Cython/Includes/cpython/genobject.pxd +25 -0
- Cython/Includes/cpython/getargs.pxd +12 -0
- Cython/Includes/cpython/instance.pxd +25 -0
- Cython/Includes/cpython/iterator.pxd +36 -0
- Cython/Includes/cpython/iterobject.pxd +24 -0
- Cython/Includes/cpython/list.pxd +92 -0
- Cython/Includes/cpython/long.pxd +149 -0
- Cython/Includes/cpython/longintrepr.pxd +14 -0
- Cython/Includes/cpython/mapping.pxd +63 -0
- Cython/Includes/cpython/marshal.pxd +66 -0
- Cython/Includes/cpython/mem.pxd +120 -0
- Cython/Includes/cpython/memoryview.pxd +50 -0
- Cython/Includes/cpython/method.pxd +49 -0
- Cython/Includes/cpython/module.pxd +208 -0
- Cython/Includes/cpython/number.pxd +258 -0
- Cython/Includes/cpython/object.pxd +433 -0
- Cython/Includes/cpython/pycapsule.pxd +143 -0
- Cython/Includes/cpython/pylifecycle.pxd +68 -0
- Cython/Includes/cpython/pyport.pxd +8 -0
- Cython/Includes/cpython/pystate.pxd +95 -0
- Cython/Includes/cpython/pythread.pxd +53 -0
- Cython/Includes/cpython/ref.pxd +67 -0
- Cython/Includes/cpython/sequence.pxd +134 -0
- Cython/Includes/cpython/set.pxd +119 -0
- Cython/Includes/cpython/slice.pxd +70 -0
- Cython/Includes/cpython/time.pxd +129 -0
- Cython/Includes/cpython/tuple.pxd +72 -0
- Cython/Includes/cpython/type.pxd +53 -0
- Cython/Includes/cpython/unicode.pxd +639 -0
- Cython/Includes/cpython/version.pxd +32 -0
- Cython/Includes/cpython/weakref.pxd +78 -0
- Cython/Includes/libc/__init__.pxd +1 -0
- Cython/Includes/libc/complex.pxd +35 -0
- Cython/Includes/libc/errno.pxd +127 -0
- Cython/Includes/libc/float.pxd +43 -0
- Cython/Includes/libc/limits.pxd +28 -0
- Cython/Includes/libc/locale.pxd +46 -0
- Cython/Includes/libc/math.pxd +209 -0
- Cython/Includes/libc/setjmp.pxd +10 -0
- Cython/Includes/libc/signal.pxd +64 -0
- Cython/Includes/libc/stddef.pxd +9 -0
- Cython/Includes/libc/stdint.pxd +105 -0
- Cython/Includes/libc/stdio.pxd +80 -0
- Cython/Includes/libc/stdlib.pxd +72 -0
- Cython/Includes/libc/string.pxd +50 -0
- Cython/Includes/libc/threads.pxd +84 -0
- Cython/Includes/libc/time.pxd +51 -0
- Cython/Includes/libcpp/__init__.pxd +4 -0
- Cython/Includes/libcpp/algorithm.pxd +320 -0
- Cython/Includes/libcpp/any.pxd +16 -0
- Cython/Includes/libcpp/atomic.pxd +59 -0
- Cython/Includes/libcpp/barrier.pxd +22 -0
- Cython/Includes/libcpp/bit.pxd +29 -0
- Cython/Includes/libcpp/cast.pxd +12 -0
- Cython/Includes/libcpp/cmath.pxd +518 -0
- Cython/Includes/libcpp/complex.pxd +106 -0
- Cython/Includes/libcpp/deque.pxd +165 -0
- Cython/Includes/libcpp/exception.pxd +86 -0
- Cython/Includes/libcpp/execution.pxd +15 -0
- Cython/Includes/libcpp/forward_list.pxd +63 -0
- Cython/Includes/libcpp/functional.pxd +26 -0
- Cython/Includes/libcpp/future.pxd +103 -0
- Cython/Includes/libcpp/iterator.pxd +34 -0
- Cython/Includes/libcpp/latch.pxd +17 -0
- Cython/Includes/libcpp/limits.pxd +61 -0
- Cython/Includes/libcpp/list.pxd +117 -0
- Cython/Includes/libcpp/map.pxd +252 -0
- Cython/Includes/libcpp/memory.pxd +115 -0
- Cython/Includes/libcpp/mutex.pxd +130 -0
- Cython/Includes/libcpp/numbers.pxd +15 -0
- Cython/Includes/libcpp/numeric.pxd +131 -0
- Cython/Includes/libcpp/optional.pxd +34 -0
- Cython/Includes/libcpp/pair.pxd +1 -0
- Cython/Includes/libcpp/queue.pxd +25 -0
- Cython/Includes/libcpp/random.pxd +166 -0
- Cython/Includes/libcpp/semaphore.pxd +44 -0
- Cython/Includes/libcpp/set.pxd +228 -0
- Cython/Includes/libcpp/shared_mutex.pxd +72 -0
- Cython/Includes/libcpp/span.pxd +87 -0
- Cython/Includes/libcpp/stack.pxd +11 -0
- Cython/Includes/libcpp/stop_token.pxd +105 -0
- Cython/Includes/libcpp/string.pxd +355 -0
- Cython/Includes/libcpp/string_view.pxd +181 -0
- Cython/Includes/libcpp/typeindex.pxd +15 -0
- Cython/Includes/libcpp/typeinfo.pxd +10 -0
- Cython/Includes/libcpp/unordered_map.pxd +193 -0
- Cython/Includes/libcpp/unordered_set.pxd +152 -0
- Cython/Includes/libcpp/utility.pxd +30 -0
- Cython/Includes/libcpp/vector.pxd +186 -0
- Cython/Includes/openmp.pxd +50 -0
- Cython/Includes/posix/__init__.pxd +1 -0
- Cython/Includes/posix/dlfcn.pxd +14 -0
- Cython/Includes/posix/fcntl.pxd +86 -0
- Cython/Includes/posix/ioctl.pxd +4 -0
- Cython/Includes/posix/mman.pxd +101 -0
- Cython/Includes/posix/resource.pxd +57 -0
- Cython/Includes/posix/select.pxd +21 -0
- Cython/Includes/posix/signal.pxd +73 -0
- Cython/Includes/posix/stat.pxd +98 -0
- Cython/Includes/posix/stdio.pxd +37 -0
- Cython/Includes/posix/stdlib.pxd +29 -0
- Cython/Includes/posix/strings.pxd +9 -0
- Cython/Includes/posix/time.pxd +71 -0
- Cython/Includes/posix/types.pxd +30 -0
- Cython/Includes/posix/uio.pxd +26 -0
- Cython/Includes/posix/unistd.pxd +271 -0
- Cython/Includes/posix/wait.pxd +38 -0
- Cython/Plex/Actions.pxd +24 -0
- Cython/Plex/Actions.py +119 -0
- Cython/Plex/DFA.pxd +14 -0
- Cython/Plex/DFA.py +164 -0
- Cython/Plex/Errors.py +48 -0
- Cython/Plex/Lexicons.py +178 -0
- Cython/Plex/Machines.pxd +36 -0
- Cython/Plex/Machines.py +238 -0
- Cython/Plex/Regexps.py +539 -0
- Cython/Plex/Scanners.pxd +47 -0
- Cython/Plex/Scanners.py +360 -0
- Cython/Plex/Transitions.pxd +14 -0
- Cython/Plex/Transitions.py +239 -0
- Cython/Plex/__init__.py +34 -0
- Cython/Runtime/__init__.py +1 -0
- Cython/Runtime/refnanny.pyx +237 -0
- Cython/Shadow.py +690 -0
- Cython/Shadow.pyi +521 -0
- Cython/StringIOTree.py +170 -0
- Cython/Tempita/__init__.py +4 -0
- Cython/Tempita/_looper.py +154 -0
- Cython/Tempita/_tempita.py +1091 -0
- Cython/TestUtils.py +410 -0
- Cython/Tests/TestCodeWriter.py +128 -0
- Cython/Tests/TestCythonUtils.py +202 -0
- Cython/Tests/TestJediTyper.py +223 -0
- Cython/Tests/TestShadow.py +114 -0
- Cython/Tests/TestStringIOTree.py +67 -0
- Cython/Tests/TestTestUtils.py +90 -0
- Cython/Tests/__init__.py +1 -0
- Cython/Tests/xmlrunner.py +390 -0
- Cython/Utility/AsyncGen.c +1002 -0
- Cython/Utility/Buffer.c +875 -0
- Cython/Utility/BufferFormatFromTypeInfo.pxd +2 -0
- Cython/Utility/Builtins.c +776 -0
- Cython/Utility/CConvert.pyx +134 -0
- Cython/Utility/CMath.c +104 -0
- Cython/Utility/CommonStructures.c +118 -0
- Cython/Utility/Complex.c +378 -0
- Cython/Utility/Coroutine.c +2206 -0
- Cython/Utility/CpdefEnums.pyx +103 -0
- Cython/Utility/CppConvert.pyx +279 -0
- Cython/Utility/CppSupport.cpp +143 -0
- Cython/Utility/CythonFunction.c +1794 -0
- Cython/Utility/Dataclasses.c +185 -0
- Cython/Utility/Dataclasses.py +112 -0
- Cython/Utility/Embed.c +125 -0
- Cython/Utility/Exceptions.c +1012 -0
- Cython/Utility/ExtensionTypes.c +809 -0
- Cython/Utility/FunctionArguments.c +965 -0
- Cython/Utility/ImportExport.c +987 -0
- Cython/Utility/Lock.c +136 -0
- Cython/Utility/MemoryView.pxd +187 -0
- Cython/Utility/MemoryView.pyx +1481 -0
- Cython/Utility/MemoryView_C.c +1046 -0
- Cython/Utility/ModuleSetupCode.c +3059 -0
- Cython/Utility/NumpyImportArray.c +46 -0
- Cython/Utility/ObjectHandling.c +3342 -0
- Cython/Utility/Optimize.c +1589 -0
- Cython/Utility/Overflow.c +404 -0
- Cython/Utility/Printing.c +86 -0
- Cython/Utility/Profile.c +709 -0
- Cython/Utility/StringTools.c +1259 -0
- Cython/Utility/TestCyUtilityLoader.pyx +8 -0
- Cython/Utility/TestCythonScope.pyx +75 -0
- Cython/Utility/TestUtilityLoader.c +12 -0
- Cython/Utility/TypeConversion.c +1284 -0
- Cython/Utility/UFuncs.pyx +50 -0
- Cython/Utility/UFuncs_C.c +89 -0
- Cython/Utility/__init__.py +28 -0
- Cython/Utility/arrayarray.h +148 -0
- Cython/Utils.py +687 -0
- Cython/__init__.py +10 -0
- Cython/__init__.pyi +7 -0
- Cython/py.typed +0 -0
- cython-3.1.0.dist-info/COPYING.txt +19 -0
- cython-3.1.0.dist-info/LICENSE.txt +176 -0
- cython-3.1.0.dist-info/METADATA +636 -0
- cython-3.1.0.dist-info/RECORD +316 -0
- cython-3.1.0.dist-info/WHEEL +5 -0
- cython-3.1.0.dist-info/entry_points.txt +4 -0
- cython-3.1.0.dist-info/top_level.txt +3 -0
- cython.py +29 -0
- pyximport/__init__.py +4 -0
- pyximport/pyxbuild.py +160 -0
- pyximport/pyximport.py +482 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from copy import deepcopy
|
|
2
|
+
from unittest import TestCase
|
|
3
|
+
|
|
4
|
+
from Cython.Compiler.FlowControl import (
|
|
5
|
+
NameAssignment, StaticAssignment, Argument, NameDeletion)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class FakeType:
|
|
9
|
+
is_pyobject = True
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class FakeNode:
|
|
13
|
+
pos = ('filename.pyx', 1, 2)
|
|
14
|
+
cf_state = None
|
|
15
|
+
type = FakeType()
|
|
16
|
+
|
|
17
|
+
def infer_type(self, scope):
|
|
18
|
+
return self.type
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class FakeEntry:
|
|
22
|
+
type = FakeType()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TestGraph(TestCase):
|
|
26
|
+
def test_deepcopy(self):
|
|
27
|
+
lhs, rhs = FakeNode(), FakeNode()
|
|
28
|
+
entry = FakeEntry()
|
|
29
|
+
entry.pos = lhs.pos
|
|
30
|
+
|
|
31
|
+
name_ass = NameAssignment(lhs, rhs, entry)
|
|
32
|
+
ass = deepcopy(name_ass)
|
|
33
|
+
self.assertTrue(ass.lhs)
|
|
34
|
+
self.assertTrue(ass.rhs)
|
|
35
|
+
self.assertTrue(ass.entry)
|
|
36
|
+
self.assertEqual(ass.pos, name_ass.pos)
|
|
37
|
+
self.assertFalse(ass.is_arg)
|
|
38
|
+
self.assertFalse(ass.is_deletion)
|
|
39
|
+
|
|
40
|
+
static_ass = StaticAssignment(entry)
|
|
41
|
+
ass = deepcopy(static_ass)
|
|
42
|
+
self.assertTrue(ass.lhs)
|
|
43
|
+
self.assertTrue(ass.rhs)
|
|
44
|
+
self.assertTrue(ass.entry)
|
|
45
|
+
self.assertEqual(ass.pos, static_ass.pos)
|
|
46
|
+
self.assertFalse(ass.is_arg)
|
|
47
|
+
self.assertFalse(ass.is_deletion)
|
|
48
|
+
|
|
49
|
+
arg_ass = Argument(lhs, rhs, entry)
|
|
50
|
+
ass = deepcopy(arg_ass)
|
|
51
|
+
self.assertTrue(ass.lhs)
|
|
52
|
+
self.assertTrue(ass.rhs)
|
|
53
|
+
self.assertTrue(ass.entry)
|
|
54
|
+
self.assertEqual(ass.pos, arg_ass.pos)
|
|
55
|
+
self.assertTrue(ass.is_arg)
|
|
56
|
+
self.assertFalse(ass.is_deletion)
|
|
57
|
+
|
|
58
|
+
name_del = NameDeletion(lhs, entry)
|
|
59
|
+
ass = deepcopy(name_del)
|
|
60
|
+
self.assertTrue(ass.lhs)
|
|
61
|
+
self.assertTrue(ass.rhs)
|
|
62
|
+
self.assertTrue(ass.entry)
|
|
63
|
+
self.assertEqual(ass.pos, name_del.pos)
|
|
64
|
+
self.assertFalse(ass.is_arg)
|
|
65
|
+
self.assertTrue(ass.is_deletion)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# mode: run
|
|
2
|
+
# tag: syntax
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
Uses TreeFragment to test invalid syntax.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import ast
|
|
10
|
+
import textwrap
|
|
11
|
+
|
|
12
|
+
from ...TestUtils import CythonTest
|
|
13
|
+
from .. import ExprNodes
|
|
14
|
+
from ..Errors import CompileError
|
|
15
|
+
|
|
16
|
+
# Copied from CPython's test_grammar.py
|
|
17
|
+
VALID_UNDERSCORE_LITERALS = [
|
|
18
|
+
'0_0_0',
|
|
19
|
+
'4_2',
|
|
20
|
+
'1_0000_0000',
|
|
21
|
+
'0b1001_0100',
|
|
22
|
+
'0xffff_ffff',
|
|
23
|
+
'0o5_7_7',
|
|
24
|
+
'1_00_00.5',
|
|
25
|
+
'1_00_00.5j',
|
|
26
|
+
'1_00_00.5e5',
|
|
27
|
+
'1_00_00j',
|
|
28
|
+
'1_00_00e5_1',
|
|
29
|
+
'1e1_0',
|
|
30
|
+
'.1_4',
|
|
31
|
+
'.1_4e1',
|
|
32
|
+
'0b_0',
|
|
33
|
+
'0x_f',
|
|
34
|
+
'0o_5',
|
|
35
|
+
'1_00_00j',
|
|
36
|
+
'1_00_00.5j',
|
|
37
|
+
'1_00_00e5_1j',
|
|
38
|
+
'.1_4j',
|
|
39
|
+
'(1_2.5+3_3j)',
|
|
40
|
+
'(.5_6j)',
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
# Copied from CPython's test_grammar.py
|
|
44
|
+
INVALID_UNDERSCORE_LITERALS = [
|
|
45
|
+
# Trailing underscores:
|
|
46
|
+
'0_',
|
|
47
|
+
'42_',
|
|
48
|
+
'1.4j_',
|
|
49
|
+
'0x_',
|
|
50
|
+
'0b1_',
|
|
51
|
+
'0xf_',
|
|
52
|
+
'0o5_',
|
|
53
|
+
'0 if 1_Else 1',
|
|
54
|
+
# Underscores in the base selector:
|
|
55
|
+
'0_b0',
|
|
56
|
+
'0_xf',
|
|
57
|
+
'0_o5',
|
|
58
|
+
# Old-style octal, still disallowed:
|
|
59
|
+
# FIXME: still need to support PY_VERSION_HEX < 3
|
|
60
|
+
'0_7',
|
|
61
|
+
'09_99',
|
|
62
|
+
# Multiple consecutive underscores:
|
|
63
|
+
'4_______2',
|
|
64
|
+
'0.1__4',
|
|
65
|
+
'0.1__4j',
|
|
66
|
+
'0b1001__0100',
|
|
67
|
+
'0xffff__ffff',
|
|
68
|
+
'0x___',
|
|
69
|
+
'0o5__77',
|
|
70
|
+
'1e1__0',
|
|
71
|
+
'1e1__0j',
|
|
72
|
+
# Underscore right before a dot:
|
|
73
|
+
'1_.4',
|
|
74
|
+
'1_.4j',
|
|
75
|
+
# Underscore right after a dot:
|
|
76
|
+
'1._4',
|
|
77
|
+
'1._4j',
|
|
78
|
+
'._5',
|
|
79
|
+
'._5j',
|
|
80
|
+
# Underscore right after a sign:
|
|
81
|
+
'1.0e+_1',
|
|
82
|
+
'1.0e+_1j',
|
|
83
|
+
# Underscore right before j:
|
|
84
|
+
'1.4_j',
|
|
85
|
+
'1.4e5_j',
|
|
86
|
+
# Underscore right before e:
|
|
87
|
+
'1_e1',
|
|
88
|
+
'1.4_e1',
|
|
89
|
+
'1.4_e1j',
|
|
90
|
+
# Underscore right after e:
|
|
91
|
+
'1e_1',
|
|
92
|
+
'1.4e_1',
|
|
93
|
+
'1.4e_1j',
|
|
94
|
+
# Complex cases with parens:
|
|
95
|
+
'(1+1.5_j_)',
|
|
96
|
+
'(1+1.5_j)',
|
|
97
|
+
# Whitespace in literals
|
|
98
|
+
'1_ 2',
|
|
99
|
+
'1 _2',
|
|
100
|
+
'1_2.2_ 1',
|
|
101
|
+
'1_2.2 _1',
|
|
102
|
+
'1_2e _1',
|
|
103
|
+
'1_2e2 _1',
|
|
104
|
+
'1_2e 2_1',
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
INVALID_ELLIPSIS = [
|
|
109
|
+
(". . .", 2, 0),
|
|
110
|
+
(". ..", 2, 0),
|
|
111
|
+
(".. .", 2, 0),
|
|
112
|
+
(". ...", 2, 0),
|
|
113
|
+
(". ... .", 2, 0),
|
|
114
|
+
(".. ... .", 2, 0),
|
|
115
|
+
(". ... ..", 2, 0),
|
|
116
|
+
("""
|
|
117
|
+
(
|
|
118
|
+
.
|
|
119
|
+
..
|
|
120
|
+
)
|
|
121
|
+
""", 3, 4),
|
|
122
|
+
("""
|
|
123
|
+
[
|
|
124
|
+
..
|
|
125
|
+
.,
|
|
126
|
+
None
|
|
127
|
+
]
|
|
128
|
+
""", 3, 4),
|
|
129
|
+
("""
|
|
130
|
+
{
|
|
131
|
+
None,
|
|
132
|
+
.
|
|
133
|
+
.
|
|
134
|
+
|
|
135
|
+
.
|
|
136
|
+
}
|
|
137
|
+
""", 4, 4)
|
|
138
|
+
]
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
class TestGrammar(CythonTest):
|
|
142
|
+
|
|
143
|
+
def test_invalid_number_literals(self):
|
|
144
|
+
for literal in INVALID_UNDERSCORE_LITERALS:
|
|
145
|
+
for expression in ['%s', '1 + %s', '%s + 1', '2 * %s', '%s * 2']:
|
|
146
|
+
code = 'x = ' + expression % literal
|
|
147
|
+
try:
|
|
148
|
+
self.fragment('''\
|
|
149
|
+
# cython: language_level=3
|
|
150
|
+
''' + code)
|
|
151
|
+
except CompileError as exc:
|
|
152
|
+
assert code in [s.strip() for s in str(exc).splitlines()], str(exc)
|
|
153
|
+
else:
|
|
154
|
+
assert False, "Invalid Cython code '%s' failed to raise an exception" % code
|
|
155
|
+
|
|
156
|
+
def test_valid_number_literals(self):
|
|
157
|
+
for literal in VALID_UNDERSCORE_LITERALS:
|
|
158
|
+
for i, expression in enumerate(['%s', '1 + %s', '%s + 1', '2 * %s', '%s * 2']):
|
|
159
|
+
code = 'x = ' + expression % literal
|
|
160
|
+
node = self.fragment('''\
|
|
161
|
+
# cython: language_level=3
|
|
162
|
+
''' + code).root
|
|
163
|
+
assert node is not None
|
|
164
|
+
|
|
165
|
+
literal_node = node.stats[0].rhs # StatListNode([SingleAssignmentNode('x', expr)])
|
|
166
|
+
if i > 0:
|
|
167
|
+
# Add/MulNode() -> literal is first or second operand
|
|
168
|
+
literal_node = literal_node.operand2 if i % 2 else literal_node.operand1
|
|
169
|
+
if 'j' in literal or 'J' in literal:
|
|
170
|
+
if '+' in literal:
|
|
171
|
+
# FIXME: tighten this test
|
|
172
|
+
assert isinstance(literal_node, ExprNodes.AddNode), (literal, literal_node)
|
|
173
|
+
else:
|
|
174
|
+
assert isinstance(literal_node, ExprNodes.ImagNode), (literal, literal_node)
|
|
175
|
+
elif '.' in literal or 'e' in literal or 'E' in literal and not ('0x' in literal or '0X' in literal):
|
|
176
|
+
assert isinstance(literal_node, ExprNodes.FloatNode), (literal, literal_node)
|
|
177
|
+
else:
|
|
178
|
+
assert isinstance(literal_node, ExprNodes.IntNode), (literal, literal_node)
|
|
179
|
+
|
|
180
|
+
def test_invalid_ellipsis(self):
|
|
181
|
+
ERR = ":{0}:{1}: Expected an identifier or literal"
|
|
182
|
+
for code, line, col in INVALID_ELLIPSIS:
|
|
183
|
+
try:
|
|
184
|
+
ast.parse(textwrap.dedent(code))
|
|
185
|
+
except SyntaxError as exc:
|
|
186
|
+
assert True
|
|
187
|
+
else:
|
|
188
|
+
assert False, "Invalid Python code '%s' failed to raise an exception" % code
|
|
189
|
+
|
|
190
|
+
try:
|
|
191
|
+
self.fragment('''\
|
|
192
|
+
# cython: language_level=3
|
|
193
|
+
''' + code)
|
|
194
|
+
except CompileError as exc:
|
|
195
|
+
assert ERR.format(line, col) in str(exc), str(exc)
|
|
196
|
+
else:
|
|
197
|
+
assert False, "Invalid Cython code '%s' failed to raise an exception" % code
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
import unittest
|
|
202
|
+
unittest.main()
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from Cython.TestUtils import CythonTest
|
|
2
|
+
import Cython.Compiler.Errors as Errors
|
|
3
|
+
from Cython.Compiler.Nodes import *
|
|
4
|
+
from Cython.Compiler.ParseTreeTransforms import *
|
|
5
|
+
from Cython.Compiler.Buffer import *
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestMemviewParsing(CythonTest):
|
|
9
|
+
|
|
10
|
+
def parse(self, s):
|
|
11
|
+
return self.should_not_fail(lambda: self.fragment(s)).root
|
|
12
|
+
|
|
13
|
+
def not_parseable(self, expected_error, s):
|
|
14
|
+
e = self.should_fail(lambda: self.fragment(s), Errors.CompileError)
|
|
15
|
+
self.assertEqual(expected_error, e.message_only)
|
|
16
|
+
|
|
17
|
+
def test_default_1dim(self):
|
|
18
|
+
self.parse("cdef int[:] x")
|
|
19
|
+
self.parse("cdef short int[:] x")
|
|
20
|
+
|
|
21
|
+
def test_default_ndim(self):
|
|
22
|
+
self.parse("cdef int[:,:,:,:,:] x")
|
|
23
|
+
self.parse("cdef unsigned long int[:,:,:,:,:] x")
|
|
24
|
+
self.parse("cdef unsigned int[:,:,:,:,:] x")
|
|
25
|
+
|
|
26
|
+
def test_zero_offset(self):
|
|
27
|
+
self.parse("cdef long double[0:] x")
|
|
28
|
+
self.parse("cdef int[0:] x")
|
|
29
|
+
|
|
30
|
+
def test_zero_offset_ndim(self):
|
|
31
|
+
self.parse("cdef int[0:,0:,0:,0:] x")
|
|
32
|
+
|
|
33
|
+
def test_def_arg(self):
|
|
34
|
+
self.parse("def foo(int[:,:] x): pass")
|
|
35
|
+
|
|
36
|
+
def test_cdef_arg(self):
|
|
37
|
+
self.parse("cdef foo(int[:,:] x): pass")
|
|
38
|
+
|
|
39
|
+
def test_general_slice(self):
|
|
40
|
+
self.parse('cdef float[::ptr, ::direct & contig, 0::full & strided] x')
|
|
41
|
+
|
|
42
|
+
def test_non_slice_memview(self):
|
|
43
|
+
self.not_parseable("An axis specification in memoryview declaration does not have a ':'.",
|
|
44
|
+
"cdef double[:foo, bar] x")
|
|
45
|
+
self.not_parseable("An axis specification in memoryview declaration does not have a ':'.",
|
|
46
|
+
"cdef double[0:foo, bar] x")
|
|
47
|
+
|
|
48
|
+
def test_basic(self):
|
|
49
|
+
t = self.parse("cdef int[:] x")
|
|
50
|
+
memv_node = t.stats[0].base_type
|
|
51
|
+
self.assertTrue(isinstance(memv_node, MemoryViewSliceTypeNode))
|
|
52
|
+
|
|
53
|
+
# we also test other similar declarations (buffers, anonymous C arrays)
|
|
54
|
+
# since the parsing has to distinguish between them.
|
|
55
|
+
|
|
56
|
+
def disable_test_no_buf_arg(self): # TODO
|
|
57
|
+
self.not_parseable("Expected ']'",
|
|
58
|
+
"cdef extern foo(object[int, ndim=2])")
|
|
59
|
+
|
|
60
|
+
def disable_test_parse_sizeof(self): # TODO
|
|
61
|
+
self.parse("sizeof(int[NN])")
|
|
62
|
+
self.parse("sizeof(int[])")
|
|
63
|
+
self.parse("sizeof(int[][NN])")
|
|
64
|
+
self.not_parseable("Expected an identifier or literal",
|
|
65
|
+
"sizeof(int[:NN])")
|
|
66
|
+
self.not_parseable("Expected ']'",
|
|
67
|
+
"sizeof(foo[dtype=bar]")
|
|
68
|
+
|
|
69
|
+
if __name__ == '__main__':
|
|
70
|
+
import unittest
|
|
71
|
+
unittest.main()
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import os.path
|
|
2
|
+
import unittest
|
|
3
|
+
|
|
4
|
+
from Cython.TestUtils import TransformTest
|
|
5
|
+
from Cython.Compiler.ParseTreeTransforms import *
|
|
6
|
+
from Cython.Compiler.ParseTreeTransforms import _calculate_pickle_checksums
|
|
7
|
+
from Cython.Compiler.Nodes import *
|
|
8
|
+
from Cython.Compiler import Main, Symtab, Options
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TestNormalizeTree(TransformTest):
|
|
12
|
+
def test_parserbehaviour_is_what_we_coded_for(self):
|
|
13
|
+
t = self.fragment("if x: y").root
|
|
14
|
+
self.assertLines("""
|
|
15
|
+
(root): StatListNode
|
|
16
|
+
stats[0]: IfStatNode
|
|
17
|
+
if_clauses[0]: IfClauseNode
|
|
18
|
+
condition: NameNode
|
|
19
|
+
body: ExprStatNode
|
|
20
|
+
expr: NameNode
|
|
21
|
+
""", self.treetypes(t))
|
|
22
|
+
|
|
23
|
+
def test_wrap_singlestat(self):
|
|
24
|
+
t = self.run_pipeline([NormalizeTree(None)], "if x: y")
|
|
25
|
+
self.assertLines("""
|
|
26
|
+
(root): StatListNode
|
|
27
|
+
stats[0]: IfStatNode
|
|
28
|
+
if_clauses[0]: IfClauseNode
|
|
29
|
+
condition: NameNode
|
|
30
|
+
body: StatListNode
|
|
31
|
+
stats[0]: ExprStatNode
|
|
32
|
+
expr: NameNode
|
|
33
|
+
""", self.treetypes(t))
|
|
34
|
+
|
|
35
|
+
def test_wrap_multistat(self):
|
|
36
|
+
t = self.run_pipeline([NormalizeTree(None)], """
|
|
37
|
+
if z:
|
|
38
|
+
x
|
|
39
|
+
y
|
|
40
|
+
""")
|
|
41
|
+
self.assertLines("""
|
|
42
|
+
(root): StatListNode
|
|
43
|
+
stats[0]: IfStatNode
|
|
44
|
+
if_clauses[0]: IfClauseNode
|
|
45
|
+
condition: NameNode
|
|
46
|
+
body: StatListNode
|
|
47
|
+
stats[0]: ExprStatNode
|
|
48
|
+
expr: NameNode
|
|
49
|
+
stats[1]: ExprStatNode
|
|
50
|
+
expr: NameNode
|
|
51
|
+
""", self.treetypes(t))
|
|
52
|
+
|
|
53
|
+
def test_statinexpr(self):
|
|
54
|
+
t = self.run_pipeline([NormalizeTree(None)], """
|
|
55
|
+
a, b = x, y
|
|
56
|
+
""")
|
|
57
|
+
self.assertLines("""
|
|
58
|
+
(root): StatListNode
|
|
59
|
+
stats[0]: SingleAssignmentNode
|
|
60
|
+
lhs: TupleNode
|
|
61
|
+
args[0]: NameNode
|
|
62
|
+
args[1]: NameNode
|
|
63
|
+
rhs: TupleNode
|
|
64
|
+
args[0]: NameNode
|
|
65
|
+
args[1]: NameNode
|
|
66
|
+
""", self.treetypes(t))
|
|
67
|
+
|
|
68
|
+
def test_wrap_offagain(self):
|
|
69
|
+
t = self.run_pipeline([NormalizeTree(None)], """
|
|
70
|
+
x
|
|
71
|
+
y
|
|
72
|
+
if z:
|
|
73
|
+
x
|
|
74
|
+
""")
|
|
75
|
+
self.assertLines("""
|
|
76
|
+
(root): StatListNode
|
|
77
|
+
stats[0]: ExprStatNode
|
|
78
|
+
expr: NameNode
|
|
79
|
+
stats[1]: ExprStatNode
|
|
80
|
+
expr: NameNode
|
|
81
|
+
stats[2]: IfStatNode
|
|
82
|
+
if_clauses[0]: IfClauseNode
|
|
83
|
+
condition: NameNode
|
|
84
|
+
body: StatListNode
|
|
85
|
+
stats[0]: ExprStatNode
|
|
86
|
+
expr: NameNode
|
|
87
|
+
""", self.treetypes(t))
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class TestWithTransform: # (TransformTest): # Disabled!
|
|
91
|
+
|
|
92
|
+
def test_simplified(self):
|
|
93
|
+
t = self.run_pipeline([WithTransform(None)], """
|
|
94
|
+
with x:
|
|
95
|
+
y = z ** 3
|
|
96
|
+
""")
|
|
97
|
+
|
|
98
|
+
self.assertCode("""
|
|
99
|
+
|
|
100
|
+
$0_0 = x
|
|
101
|
+
$0_2 = $0_0.__exit__
|
|
102
|
+
$0_0.__enter__()
|
|
103
|
+
$0_1 = True
|
|
104
|
+
try:
|
|
105
|
+
try:
|
|
106
|
+
$1_0 = None
|
|
107
|
+
y = z ** 3
|
|
108
|
+
except:
|
|
109
|
+
$0_1 = False
|
|
110
|
+
if (not $0_2($1_0)):
|
|
111
|
+
raise
|
|
112
|
+
finally:
|
|
113
|
+
if $0_1:
|
|
114
|
+
$0_2(None, None, None)
|
|
115
|
+
|
|
116
|
+
""", t)
|
|
117
|
+
|
|
118
|
+
def test_basic(self):
|
|
119
|
+
t = self.run_pipeline([WithTransform(None)], """
|
|
120
|
+
with x as y:
|
|
121
|
+
y = z ** 3
|
|
122
|
+
""")
|
|
123
|
+
self.assertCode("""
|
|
124
|
+
|
|
125
|
+
$0_0 = x
|
|
126
|
+
$0_2 = $0_0.__exit__
|
|
127
|
+
$0_3 = $0_0.__enter__()
|
|
128
|
+
$0_1 = True
|
|
129
|
+
try:
|
|
130
|
+
try:
|
|
131
|
+
$1_0 = None
|
|
132
|
+
y = $0_3
|
|
133
|
+
y = z ** 3
|
|
134
|
+
except:
|
|
135
|
+
$0_1 = False
|
|
136
|
+
if (not $0_2($1_0)):
|
|
137
|
+
raise
|
|
138
|
+
finally:
|
|
139
|
+
if $0_1:
|
|
140
|
+
$0_2(None, None, None)
|
|
141
|
+
|
|
142
|
+
""", t)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class TestInterpretCompilerDirectives(TransformTest):
|
|
146
|
+
"""
|
|
147
|
+
This class tests the parallel directives AST-rewriting and importing.
|
|
148
|
+
"""
|
|
149
|
+
|
|
150
|
+
# Test the parallel directives (c)importing
|
|
151
|
+
|
|
152
|
+
import_code = """
|
|
153
|
+
cimport cython.parallel
|
|
154
|
+
cimport cython.parallel as par
|
|
155
|
+
from cython cimport parallel as par2
|
|
156
|
+
from cython cimport parallel
|
|
157
|
+
|
|
158
|
+
from cython.parallel cimport threadid as tid
|
|
159
|
+
from cython.parallel cimport threadavailable as tavail
|
|
160
|
+
from cython.parallel cimport prange
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
expected_directives_dict = {
|
|
164
|
+
'cython.parallel': 'cython.parallel',
|
|
165
|
+
'par': 'cython.parallel',
|
|
166
|
+
'par2': 'cython.parallel',
|
|
167
|
+
'parallel': 'cython.parallel',
|
|
168
|
+
|
|
169
|
+
"tid": "cython.parallel.threadid",
|
|
170
|
+
"tavail": "cython.parallel.threadavailable",
|
|
171
|
+
"prange": "cython.parallel.prange",
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def setUp(self):
|
|
176
|
+
super().setUp()
|
|
177
|
+
|
|
178
|
+
compilation_options = Options.CompilationOptions(Options.default_options)
|
|
179
|
+
ctx = Main.Context.from_options(compilation_options)
|
|
180
|
+
|
|
181
|
+
transform = InterpretCompilerDirectives(ctx, ctx.compiler_directives)
|
|
182
|
+
transform.module_scope = Symtab.ModuleScope('__main__', None, ctx)
|
|
183
|
+
self.pipeline = [transform]
|
|
184
|
+
|
|
185
|
+
self.debug_exception_on_error = DebugFlags.debug_exception_on_error
|
|
186
|
+
|
|
187
|
+
def tearDown(self):
|
|
188
|
+
DebugFlags.debug_exception_on_error = self.debug_exception_on_error
|
|
189
|
+
|
|
190
|
+
def test_parallel_directives_cimports(self):
|
|
191
|
+
self.run_pipeline(self.pipeline, self.import_code)
|
|
192
|
+
parallel_directives = self.pipeline[0].parallel_directives
|
|
193
|
+
self.assertEqual(parallel_directives, self.expected_directives_dict)
|
|
194
|
+
|
|
195
|
+
def test_parallel_directives_imports(self):
|
|
196
|
+
self.run_pipeline(self.pipeline,
|
|
197
|
+
self.import_code.replace('cimport', 'import'))
|
|
198
|
+
parallel_directives = self.pipeline[0].parallel_directives
|
|
199
|
+
self.assertEqual(parallel_directives, self.expected_directives_dict)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
# TODO: Re-enable once they're more robust.
|
|
203
|
+
if False:
|
|
204
|
+
from Cython.Debugger import DebugWriter
|
|
205
|
+
from Cython.Debugger.Tests.TestLibCython import DebuggerTestCase
|
|
206
|
+
else:
|
|
207
|
+
# skip test, don't let it inherit unittest.TestCase
|
|
208
|
+
DebuggerTestCase = object
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class TestDebugTransform(DebuggerTestCase):
|
|
212
|
+
|
|
213
|
+
def elem_hasattrs(self, elem, attrs):
|
|
214
|
+
return all(attr in elem.attrib for attr in attrs)
|
|
215
|
+
|
|
216
|
+
def test_debug_info(self):
|
|
217
|
+
try:
|
|
218
|
+
assert os.path.exists(self.debug_dest)
|
|
219
|
+
|
|
220
|
+
t = DebugWriter.etree.parse(self.debug_dest)
|
|
221
|
+
# the xpath of the standard ElementTree is primitive, don't use
|
|
222
|
+
# anything fancy
|
|
223
|
+
L = list(t.find('/Module/Globals'))
|
|
224
|
+
assert L
|
|
225
|
+
xml_globals = {e.attrib['name']: e.attrib['type'] for e in L}
|
|
226
|
+
self.assertEqual(len(L), len(xml_globals))
|
|
227
|
+
|
|
228
|
+
L = list(t.find('/Module/Functions'))
|
|
229
|
+
assert L
|
|
230
|
+
xml_funcs = {e.attrib['qualified_name']: e for e in L}
|
|
231
|
+
self.assertEqual(len(L), len(xml_funcs))
|
|
232
|
+
|
|
233
|
+
# test globals
|
|
234
|
+
self.assertEqual('CObject', xml_globals.get('c_var'))
|
|
235
|
+
self.assertEqual('PythonObject', xml_globals.get('python_var'))
|
|
236
|
+
|
|
237
|
+
# test functions
|
|
238
|
+
funcnames = ('codefile.spam', 'codefile.ham', 'codefile.eggs',
|
|
239
|
+
'codefile.closure', 'codefile.inner')
|
|
240
|
+
required_xml_attrs = 'name', 'cname', 'qualified_name'
|
|
241
|
+
assert all(f in xml_funcs for f in funcnames)
|
|
242
|
+
spam, ham, eggs = [xml_funcs[funcname] for funcname in funcnames]
|
|
243
|
+
|
|
244
|
+
self.assertEqual(spam.attrib['name'], 'spam')
|
|
245
|
+
self.assertNotEqual('spam', spam.attrib['cname'])
|
|
246
|
+
assert self.elem_hasattrs(spam, required_xml_attrs)
|
|
247
|
+
|
|
248
|
+
# test locals of functions
|
|
249
|
+
spam_locals = list(spam.find('Locals'))
|
|
250
|
+
assert spam_locals
|
|
251
|
+
spam_locals.sort(key=lambda e: e.attrib['name'])
|
|
252
|
+
names = [e.attrib['name'] for e in spam_locals]
|
|
253
|
+
self.assertEqual(list('abcd'), names)
|
|
254
|
+
assert self.elem_hasattrs(spam_locals[0], required_xml_attrs)
|
|
255
|
+
|
|
256
|
+
# test arguments of functions
|
|
257
|
+
spam_arguments = list(spam.find('Arguments'))
|
|
258
|
+
assert spam_arguments
|
|
259
|
+
self.assertEqual(1, len(list(spam_arguments)))
|
|
260
|
+
|
|
261
|
+
# test step-into functions
|
|
262
|
+
step_into = spam.find('StepIntoFunctions')
|
|
263
|
+
spam_stepinto = [x.attrib['name'] for x in step_into]
|
|
264
|
+
assert spam_stepinto
|
|
265
|
+
self.assertEqual(2, len(spam_stepinto))
|
|
266
|
+
assert 'puts' in spam_stepinto
|
|
267
|
+
assert 'some_c_function' in spam_stepinto
|
|
268
|
+
except:
|
|
269
|
+
f = open(self.debug_dest)
|
|
270
|
+
try:
|
|
271
|
+
print(f.read())
|
|
272
|
+
finally:
|
|
273
|
+
f.close()
|
|
274
|
+
raise
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class TestAnalyseDeclarationsTransform(unittest.TestCase):
|
|
278
|
+
def test_calculate_pickle_checksums(self):
|
|
279
|
+
checksums = _calculate_pickle_checksums(['member1', 'member2', 'member3'])
|
|
280
|
+
assert 2 <= len(checksums) <= 3, checksums # expecting ['0xc0af380' (MD5), '0x0c75bd4', '0xa7a7b94']
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
if __name__ == "__main__":
|
|
284
|
+
import unittest
|
|
285
|
+
unittest.main()
|