From d46467f5262ab3a2cdbdc2dd19ac0a2e46e365f0 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Fri, 22 Feb 2019 12:16:34 +0000 Subject: [PATCH] Python: Update tests to account for packages having locations. --- .../library-tests/PointsTo/new/PointsToWithContext.expected | 1 + .../test/library-tests/PointsTo/new/PointsToWithType.expected | 1 + python/ql/test/library-tests/PointsTo/new/Sanity.ql | 2 ++ 3 files changed, 4 insertions(+) diff --git a/python/ql/test/library-tests/PointsTo/new/PointsToWithContext.expected b/python/ql/test/library-tests/PointsTo/new/PointsToWithContext.expected index 811df60fc98..cd5e3cdfae5 100755 --- a/python/ql/test/library-tests/PointsTo/new/PointsToWithContext.expected +++ b/python/ql/test/library-tests/PointsTo/new/PointsToWithContext.expected @@ -403,6 +403,7 @@ | i_imports.py:18 | ControlFlowNode for sys | Module sys | builtin-class module | 17 | import | | i_imports.py:23 | ControlFlowNode for ImportExpr | Module code | builtin-class module | 23 | import | | i_imports.py:23 | ControlFlowNode for code | Module code | builtin-class module | 23 | import | +| i_imports.py:24 | ControlFlowNode for Attribute | Module code.package | builtin-class module | 0 | import | | i_imports.py:24 | ControlFlowNode for Attribute | Module code.package.x | builtin-class module | 0 | import | | i_imports.py:24 | ControlFlowNode for code | Module code | builtin-class module | 23 | import | | i_imports.py:27 | ControlFlowNode for ImportExpr | Module code.test_package | builtin-class module | 27 | import | diff --git a/python/ql/test/library-tests/PointsTo/new/PointsToWithType.expected b/python/ql/test/library-tests/PointsTo/new/PointsToWithType.expected index f3fc21e75b5..86e75f991cb 100644 --- a/python/ql/test/library-tests/PointsTo/new/PointsToWithType.expected +++ b/python/ql/test/library-tests/PointsTo/new/PointsToWithType.expected @@ -512,6 +512,7 @@ | i_imports.py:18 | ControlFlowNode for sys | Module sys | builtin-class module | 17 | | i_imports.py:23 | ControlFlowNode for ImportExpr | Module code | builtin-class module | 23 | | i_imports.py:23 | ControlFlowNode for code | Module code | builtin-class module | 23 | +| i_imports.py:24 | ControlFlowNode for Attribute | Module code.package | builtin-class module | 0 | | i_imports.py:24 | ControlFlowNode for Attribute | Module code.package.x | builtin-class module | 0 | | i_imports.py:24 | ControlFlowNode for code | Module code | builtin-class module | 23 | | i_imports.py:27 | ControlFlowNode for ImportExpr | Module code.test_package | builtin-class module | 27 | diff --git a/python/ql/test/library-tests/PointsTo/new/Sanity.ql b/python/ql/test/library-tests/PointsTo/new/Sanity.ql index 94c7dfa1815..496a751cd2b 100644 --- a/python/ql/test/library-tests/PointsTo/new/Sanity.ql +++ b/python/ql/test/library-tests/PointsTo/new/Sanity.ql @@ -95,9 +95,11 @@ predicate ssa_sanity(string clsname, string problem, string what) { not exists(m.getName()) and problem = "does not have a name" or + not m.isPackage() and not exists(Variable v | v.getId() = "__name__" and v.getScope() = m) and problem = "does not have a __name__ variable" or + not m.isPackage() and not exists(PyNodeDefinition def | def.getDefiningNode().getScope() = m and def.getVariable().getName() = "__name__"