Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error for python 3.11 File "<frozen runpy>, line 198, in _ron_module_as_main #52

Closed
fhg-isi opened this issue Nov 2, 2023 · 4 comments

Comments

@fhg-isi
Copy link

fhg-isi commented Nov 2, 2023

If I try to use pynguin with following command and Python 3.11.1 on Windows:

pynguin --project-path ./src --output-path ./test --module-name example

I get following error:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main                                                                   
  File "<frozen runpy>", line 88, in _run_code                                                                              
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Scripts\pynguin.exe\__main__.py", line 4, in <module>               
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\__init__.py", line 9, in <module>         
    import pynguin.generator as gen                                                                                         
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\generator.py", line 31, in <module>       
    import pynguin.analyses.seeding as seeding  # pylint: disable=consider-using-from-import                                
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                              
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\analyses\seeding.py", line 25, in <module>
    import pynguin.ga.testcasechromosome as tcc                                                                             
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\ga\testcasechromosome.py", line 13, in <module>
    import pynguin.ga.chromosome as chrom
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\ga\chromosome.py", line 13, in <module>
    import pynguin.ga.computations as ff
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\ga\computations.py", line 17, in <module>
    from pynguin.testcase.execution import ExecutionTrace
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\testcase\execution.py", line 425, in <module>
    class ExecutionTracer:
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\site-packages\pynguin\testcase\execution.py", line 460, in ExecutionTracer
    Compare.IN: lambda val1, val2: (
    ^^^^^^^^^^
  File "C:\python_env\App\WinPython\python-3.11.1.amd64\Lib\enum.py", line 787, in __getattr__
    raise AttributeError(name) from None
AttributeError: IN

=> Could you please update pynguin to work with Python 3.11?

@stephanlukasczyk
Copy link
Member

Updating Pynguin to Python 3.11 is considerable effort, because it would require to revisit and rework the instrumentation of Python's bytecode. Unfortunately, I currently do not have capacity to do this, although I am happy to accept pull requests for this.

Besides, I think that if I invest the time to support a newer Python version, I'd go with the current Python 3.12, using its new sys.monitoring API.

I hope you can understand this decision and use Pynguin on Python 3.10.

@fhg-isi
Copy link
Author

fhg-isi commented Nov 3, 2023

Sure, many thanks for quick clarification and your efforts.
For others looking for a unit test generation solution also see related SO question:
https://stackoverflow.com/questions/77409726/ho-to-generate-unit-tests-for-python-in-pycharm-using-src-and-test-folder-stru

@fhg-isi fhg-isi closed this as completed Nov 3, 2023
@ghostbody
Copy link

@stephanlukasczyk May this project help you to upgrade to python 3.12 ~

https://github.com/asottile/pyupgrade

@stephanlukasczyk
Copy link
Member

@ghostbody I know about pyupgrade, it's already being used as a pre-commit hook in Pynguin. However, migrating is not that easy. I am pretty sure that most of the code of Pynguin will run on Python 3.12 without any changes. But I know one, central, module that requires changes; changes that pyupgrade will not be helpful: the instrumentation of the Python bytecode to measure coverage and the like. It changes the bytecode of Python directly and the bytecode is an implementation detail of the CPython interpreter (one of the reasons why Pynguin does not run on other interpreters, e.g., PyPy), which changes with almost every version. I know of bytecode changes between Python 3.10, 3.11, and 3.12. These need to be addressed manually, for which I currently do not have time (though I am happy to accept pull requests).

Besides, for Python 3.12 and the future it might be wise to use the aforementioned sys.monitoring API instead of manipulating the bytecode directly. My hope would be that such an approach could be more stable and also would work in Python 3.13 without any changes. Again, I am happy to accept pull requests for this, but I cannot do it by myself currently. Finishing my PhD first is required 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants