Python: Make ModelUsage test language agnostic

This commit is contained in:
Rasmus Wriedt Larsen
2020-02-14 17:50:46 +01:00
parent 87eff7f062
commit 0509228296
2 changed files with 11 additions and 8 deletions

View File

@@ -1,4 +1,3 @@
| file://:0:0:0:0 | Module builtins | isUsedAsModule |
| file://:0:0:0:0 | Module sys | isUsedAsModule |
| imported.py:0:0:0:0 | Module imported | isUsedAsModule |
| main.py:0:0:0:0 | Module main | isUsedAsScript |

View File

@@ -2,11 +2,15 @@ import python
from ModuleValue mv, string usage
where
mv.isUsedAsModule() and usage = "isUsedAsModule"
or
mv.isUsedAsScript() and usage = "isUsedAsScript"
or
not mv.isUsedAsModule() and
not mv.isUsedAsScript() and
usage = "<UNKNOWN>"
// builtin module has different name in Python 2 and 3
not mv = Module::builtinModule() and
(
mv.isUsedAsModule() and usage = "isUsedAsModule"
or
mv.isUsedAsScript() and usage = "isUsedAsScript"
or
not mv.isUsedAsModule() and
not mv.isUsedAsScript() and
usage = "<UNKNOWN>"
)
select mv, usage