Repository: alexmojaki/executing (language: python)

Issue:
tests are failing for storing to two attributes with the same name
I'm currently working on #64 and have some problems with the tests for 3.7 (reproducible on master)

The pipeline which is failing is the following:
https://github.com/alexmojaki/executing/actions/runs/4362346591/jobs/7627135034

I minimized the problem down to the following line (file was stored in tests/small_samples):

``` python
__arg.__deprecated__ = __new__.__deprecated__ = __msg
```

part of the test output (python 3.7.15):
```
mapping failed
Expected one value, found 2
search bytecode Instruction(opname='STORE_ATTR', opcode=95, arg=2, argval='__deprecated__', argrepr='__deprecated__', offset=6, starts_line=None, is_jump_target=False)
```

I don't know if this issue could be fixed in the SentinelNodeFinder or if it should be handled as an known issue and be ignored.

I also don't know why it started to appear now.






Discussion / hints:
It's a known issue that should be ignored.

https://github.com/alexmojaki/executing/blob/0e5096a4506e2f0d84fe306516fbb89003eaa8a8/tests/test_main.py#L837-L841
Interesting. I will try to figure out why it is not. Thank you.

the error is already handled here and raised in the last line.

https://github.com/alexmojaki/executing/blob/0e5096a4506e2f0d84fe306516fbb89003eaa8a8/tests/test_main.py#L1246-L1303

The code that you mentioned is never executed in this case.
I think the problem are the open issues in the SentinelNodeFinder.

https://github.com/alexmojaki/executing/blob/0e5096a4506e2f0d84fe306516fbb89003eaa8a8/tests/test_main.py#L679-L685

This issue here is just one more. I skipped `test_module_files` in #64 for python < 3.8 for now.

This issues should be fixed later or categorized as KnownIssues.

But don't know if I will have time for this.

Fix patch:
diff --git a/setup.cfg b/setup.cfg
index d22b4e2..3ee513e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -32,7 +32,10 @@ install_requires =
 [options.extras_require]
 tests=
     asttokens>=2.1.0
+    ipython
     pytest
+    coverage
+    coverage-enable-subprocess
     littleutils
     rich; python_version >='3.11'
 
@@ -41,6 +44,9 @@ executing = py.typed
 
 [coverage:run]
 relative_files = True
+include = executing/executing.py
+parallel = true
+branch = true
 
 [bdist_wheel]
 universal=1


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 7cd07b1..2a31da2 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -40,7 +40,11 @@ jobs:
       env:
         EXECUTING_SLOW_TESTS: 1
       run: |
-        coverage run --include=executing/executing.py --append -m pytest tests
+        # COVERAGE_PROCESS_START defines the path to the coverage config for coverage-enable-subprocess
+        export COVERAGE_PROCESS_START=${GITHUB_WORKSPACE}/setup.cfg
+        coverage run -m pytest tests
+        # combine the coverage of all subprocesses
+        coverage combine
         coverage report -m
     - name: Coveralls Python
       uses: AndreMiras/coveralls-python-action@v20201129
diff --git a/tests/test_ipython.py b/tests/test_ipython.py
new file mode 100644
index 0000000..dbdd662
--- /dev/null
+++ b/tests/test_ipython.py
@@ -0,0 +1,41 @@
+import subprocess as sp
+import sys
+import pytest
+
+
+def run(input):
+    p = sp.run(
+        [sys.executable, "-m", "IPython", "--colors=nocolor", "--simple-prompt"],
+        input=input.encode("utf8"),
+        stdout=sp.PIPE,
+    )
+    output = p.stdout.decode("utf8")
+    print(output)
+    return output
+
+
+test_function_code = """
+from executing import Source
+import inspect
+import ast
+
+def test():
+    frame = inspect.currentframe()
+    ex = Source.executing(frame.f_back)
+    print(ex.node)
+    if not isinstance(ex.node,ast.Call):
+        print("test failure")
+    if not ex.node.func.id=="test":
+        print("test failure")
+
+"""
+
+
+def test_one_lookup():
+    p = run(test_function_code + "test()")
+    assert "test failure" not in p
+
+
+def test_two_statement_lookups():
+    p = run(test_function_code + "test();test()")
+    assert "test failure" in p