Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,92 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# py500
|
| 6 |
+
|
| 7 |
+
## Human-level test oracle generation in real-world Python repositories.
|
| 8 |
+
|
| 9 |
+
Here is an example:
|
| 10 |
+
|
| 11 |
+
```json
|
| 12 |
+
{
|
| 13 |
+
"index": 0,
|
| 14 |
+
"repo_name": "black",
|
| 15 |
+
"github": "https://github.com/psf/black.git",
|
| 16 |
+
"version": "25.9.0",
|
| 17 |
+
"install_cmd": "python -m venv .venv\nsource .venv/bin/activate\npip install -r test_requirements.txt\npip install -e .\npip install ipdb",
|
| 18 |
+
"activate_cmd": "source .venv/bin/activate\nhash -r",
|
| 19 |
+
"test_function_name": "test_pep_572_version_detection",
|
| 20 |
+
"test_class_name": "BlackTestCase",
|
| 21 |
+
"original_test_prefix": " def test_pep_572_version_detection(self) -> None:\n source, _ = read_data(\"cases\", \"pep_572\")\n root = black.lib2to3_parse(source)\n features = black.get_features_used(root)\n self.assertIn(black.Feature.ASSIGNMENT_EXPRESSIONS, features)\n versions = black.detect_target_versions(root)\n self.assertIn(black.TargetVersion.PY38, versions)",
|
| 22 |
+
"test_prefix": " def test_pep_572_version_detection(self) -> None:\n source, _ = read_data(\"cases\", \"pep_572\")\n root = black.lib2to3_parse(source)\n features = black.get_features_used(root)\n self.assertIn(black.Feature.ASSIGNMENT_EXPRESSIONS, features)\n versions = black.detect_target_versions(root)\n <AssertPlaceHolder>",
|
| 23 |
+
"test_prefix_file_path": "tests/test_black.py",
|
| 24 |
+
"test_prefix_start_lineno": 243,
|
| 25 |
+
"test_prefix_end_lineno": 249,
|
| 26 |
+
"test_target": "tests/test_black.py::BlackTestCase::test_pep_572_version_detection",
|
| 27 |
+
"ground_truth_oracle": "self.assertIn(black.TargetVersion.PY38, versions)",
|
| 28 |
+
"ground_truth_oracle_lineno": 249,
|
| 29 |
+
"test_setup": "",
|
| 30 |
+
"test_setup_file_path": "",
|
| 31 |
+
"test_setup_start_lineno": -1,
|
| 32 |
+
"test_setup_end_lineno": -1,
|
| 33 |
+
"focal_method": "def detect_target_versions(\n node: Node, *, future_imports: Optional[set[str]] = None\n) -> set[TargetVersion]:\n \"\"\"Detect the version to target based on the nodes used.\"\"\"\n features = get_features_used(node, future_imports=future_imports)\n return {\n version for version in TargetVersion if features <= VERSION_TO_FEATURES[version]\n }",
|
| 34 |
+
"focal_method_file_path": "src/black/__init__.py",
|
| 35 |
+
"focal_method_start_lineno": 1510,
|
| 36 |
+
"focal_method_end_lineno": 1517
|
| 37 |
+
}
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
- Focal method
|
| 42 |
+
```
|
| 43 |
+
def detect_target_versions(
|
| 44 |
+
node: Node, *, future_imports: Optional[set[str]] = None
|
| 45 |
+
) -> set[TargetVersion]:
|
| 46 |
+
"""Detect the version to target based on the nodes used."""
|
| 47 |
+
features = get_features_used(node, future_imports=future_imports)
|
| 48 |
+
return {
|
| 49 |
+
version for version in TargetVersion if features <= VERSION_TO_FEATURES[version]
|
| 50 |
+
}
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
- Test setup
|
| 54 |
+
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
- Test prefix
|
| 60 |
+
|
| 61 |
+
```
|
| 62 |
+
def test_pep_572_version_detection(self) -> None:
|
| 63 |
+
source, _ = read_data("cases", "pep_572")
|
| 64 |
+
root = black.lib2to3_parse(source)
|
| 65 |
+
features = black.get_features_used(root)
|
| 66 |
+
self.assertIn(black.Feature.ASSIGNMENT_EXPRESSIONS, features)
|
| 67 |
+
versions = black.detect_target_versions(root)
|
| 68 |
+
<AssertPlaceHolder>
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
- Ground truth oracle
|
| 72 |
+
```
|
| 73 |
+
self.assertIn(black.TargetVersion.PY38, versions)
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
### Install
|
| 77 |
+
|
| 78 |
+
Install venv
|
| 79 |
+
|
| 80 |
+
`install.py`
|
| 81 |
+
|
| 82 |
+
### Run
|
| 83 |
+
|
| 84 |
+
Run the ground truth oracle
|
| 85 |
+
|
| 86 |
+
`run.py`
|
| 87 |
+
|
| 88 |
+
### Evaluate
|
| 89 |
+
|
| 90 |
+
Evaluate whether an oracle is same with the ground truth
|
| 91 |
+
|
| 92 |
+
`evaluate.py`
|