- Notifications
You must be signed in to change notification settings - Fork 45
UTBot Python updates from SBFT version #2725
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits Select commit Hold shift + click to select a range
96b3415 Updates from sbft version
tamarinvs19 ac4d801 Updates cli README.md
tamarinvs19 6daa50a Updates cli README.md
tamarinvs19 e97c54f Rewrite definition getter without try-except
tamarinvs19 8d23df8 Remove unused ClassCastException
tamarinvs19 fd9ff91 Update utbot_mypy_runner_version
tamarinvs19 805cbd3 Updates cli README.md
tamarinvs19 c1a0dc2 Add args checking
tamarinvs19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Updates from sbft version
- Loading branch information
commit 96b3415dddf917c43411bf71fc01759b505fbfcc
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions 10 utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonCliProcessor.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
375 changes: 220 additions & 155 deletions 375 utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/PythonGenerateTestsCommand.kt
Large diffs are not rendered by default.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions 27 utbot-cli-python/src/main/kotlin/org/utbot/cli/language/python/TestWriter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package org.utbot.cli.language.python | ||
| | ||
| class TestWriter { | ||
| private val testCode: MutableList<String> = mutableListOf() | ||
| | ||
| fun addTestCode(code: String) { | ||
| testCode.add(code) | ||
| } | ||
| | ||
| fun generateTestCode(): String { | ||
| val (importLines, code) = testCode.fold(mutableListOf<String>() to StringBuilder()) { acc, s -> | ||
| val lines = s.split(System.lineSeparator()) | ||
| val firstClassIndex = lines.indexOfFirst { it.startsWith("class") } | ||
| lines.take(firstClassIndex).forEach { line -> if (line !in acc.first) acc.first.add(line) } | ||
| lines.drop(firstClassIndex).forEach { line -> acc.second.append(line + System.lineSeparator()) } | ||
| acc.first to acc.second | ||
| } | ||
| val codeBuilder = StringBuilder() | ||
| importLines.filter { it.isNotEmpty() }.forEach { | ||
| codeBuilder.append(it) | ||
| codeBuilder.append(System.lineSeparator()) | ||
| } | ||
| codeBuilder.append(System.lineSeparator()) | ||
| codeBuilder.append(code) | ||
| return codeBuilder.toString() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -23,4 +23,5 @@ env/ | |
| venv/ | ||
| .mypy_cache/ | ||
| .dmypy.json | ||
| dmypy.json | ||
| dmypy.json | ||
| utbot_executor.iml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
File renamed without changes.
45 changes: 45 additions & 0 deletions 45 utbot-python-executor/src/main/python/utbot_executor/tests/example/example.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import random | ||
| | ||
| from utbot_executor.config import CoverageConfig, HostConfig | ||
| from utbot_executor.executor import PythonExecutor | ||
| from utbot_executor.parser import ExecutionRequest, ExecutionSuccessResponse, MemoryMode | ||
| from utbot_executor.utils import TraceMode | ||
| | ||
| | ||
| def test_execution(): | ||
| executor = PythonExecutor( | ||
| CoverageConfig(HostConfig("localhost", random.randint(10 ** 5, 10 ** 6)), TraceMode.Instructions, True), False) | ||
| id_ = '1500926645' | ||
| serialized_arg = (r'{"objects":{"1500926644":{"strategy":"repr","id":"1500926644","typeinfo":{"module":"builtins",' | ||
| r'"kind":"int"},"comparable":true,"value":"170141183460469231731687303715749887999"},' | ||
| r'"1500926652":{"strategy":"list","id":"1500926652","typeinfo":{"module":"builtins",' | ||
| r'"kind":"list"},"comparable":true,"items":["1500926644"]},"1500926650":{"strategy":"repr",' | ||
| r'"id":"1500926650","typeinfo":{"module":"builtins","kind":"str"},"comparable":true,' | ||
| r'"value":"\"x\""},"1500926646":{"strategy":"repr","id":"1500926646","typeinfo":{' | ||
| r'"module":"builtins","kind":"int"},"comparable":true,"value":"1"},"1500926651":{' | ||
| r'"strategy":"dict","id":"1500926651","typeinfo":{"module":"builtins","kind":"dict"},' | ||
| r'"comparable":true,"items":{"1500926650":"1500926646"}},"1500926653":{"strategy":"list",' | ||
| r'"id":"1500926653","typeinfo":{"module":"builtins","kind":"list"},"comparable":true,' | ||
| r'"items":[]},"1500926654":{"strategy":"dict","id":"1500926654","typeinfo":{' | ||
| r'"module":"builtins","kind":"dict"},"comparable":true,"items":{}},"1500926645":{' | ||
| r'"strategy":"reduce","id":"1500926645","typeinfo":{"module":"my_func","kind":"A"},' | ||
| r'"comparable":true,"constructor":{"module":"my_func","kind":"A"},"args":"1500926652",' | ||
| r'"state":"1500926651","listitems":"1500926653","dictitems":"1500926654"}}}') | ||
| request = ExecutionRequest( | ||
| 'f', | ||
| 'my_func', | ||
| ['my_func'], | ||
| ['./'], | ||
| [id_], | ||
| {}, | ||
| serialized_arg, | ||
| MemoryMode.REDUCE, | ||
| 'my_func.py', | ||
| '0x1', | ||
| ) | ||
| response = executor.run_reduce_function(request) | ||
| | ||
| assert isinstance(response, ExecutionSuccessResponse) | ||
| | ||
| assert response.status == "success" | ||
| assert response.is_exception is False |
File renamed without changes.
1 change: 1 addition & 0 deletions 1 utbot-python-executor/src/main/python/utbot_executor/tests/example_input.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {"functionName":"im_list","functionModule":"src.foo.foo","imports":["typing","builtins","src.foo.foo"],"syspaths":["/home/vyacheslav/PycharmProjects/pythonProject/src","/home/vyacheslav/PycharmProjects/pythonProject"],"argumentsIds":["1500000001"],"kwargumentsIds":{},"serializedMemory":"{\"objects\":{\"1500000002\":{\"strategy\":\"repr\",\"id\":\"1500000002\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"9\"},\"1500000003\":{\"strategy\":\"repr\",\"id\":\"1500000003\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"1\"},\"1500000004\":{\"strategy\":\"repr\",\"id\":\"1500000004\",\"typeinfo\":{\"module\":\"builtins\",\"kind\":\"int\"},\"comparable\":true,\"value\":\"0\"},\"1500000001\":{\"strategy\":\"iterator\",\"id\":\"1500000001\",\"typeinfo\":{\"module\":\"typing\",\"kind\":\"Iterator\"},\"comparable\":true,\"items\":[\"1500000002\",\"1500000003\",\"1500000004\"],\"exception\":{\"module\":\"builtins\",\"kind\":\"StopIteration\"}}}}","memoryMode":"REDUCE","filepath":"/home/vyacheslav/PycharmProjects/pythonProject/src/foo/foo.py","coverageId":"59682f01"} |
2 changes: 0 additions & 2 deletions 2 utbot-python-executor/src/main/python/utbot_executor/tests/pytest.ini
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably do not support Python 3.12: there were changes in syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated comment