Download backend/tests/test_inputs.py from SevdanurGenc/LLM-Automated-Test-Generation-Agent: direct link, hf CLI and curl.
- Browser
- Download file 2.94 kB
-
https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/backend/tests/test_inputs.py
- Command line
-
hf download hf://SevdanurGenc/LLM-Automated-Test-Generation-Agent/backend/tests/test_inputs.py
-
curl -L -o test_inputs.py https://huggingface.co/SevdanurGenc/LLM-Automated-Test-Generation-Agent/resolve/main/backend/tests/test_inputs.py
2.94 kB
| """Dışarıdan eklenen dosyalarla ilgili düzeltmeler (kullanıcı otomasyonunda bulunan sorunlar).""" | |
| from __future__ import annotations | |
| import os | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| os.environ.setdefault("SANDBOX_MODE", "local") | |
| from app.models import JobRequest, looks_typescript # noqa: E402 | |
| from app.sandbox.registry import get_runner # noqa: E402 | |
| CALC = "package com.example;\r\n\r\npublic class Calculator {\r\n public int twice(int x) { return 2 * x; }\r\n}\r\n" | |
| INV = ("package com.example.inventory;\r\n\r\nimport java.util.*;\r\n\r\npublic class InventoryManager {\r\n" | |
| " private final Map<String, Integer> stock = new HashMap<>();\r\n" | |
| " public void add(String id, int n) { stock.merge(id, n, Integer::sum); }\r\n" | |
| " public int get(String id) { return stock.getOrDefault(id, 0); }\r\n}\r\n") | |
| def test_java_helper_named_after_its_public_class(tmp_path): | |
| j = get_runner("java") | |
| wd = j.materialize(CALC, "package com.example;\npublic class CalculatorTest {}\n", "unit", | |
| extra={"Test02.java": INV}, source_name="Test01.java") | |
| assert (wd / "src/main/com/example/inventory/InventoryManager.java").exists() | |
| assert not list(wd.rglob("Test02.java")) | |
| if j.framework() == "missing": | |
| return | |
| junit5 = j.framework() == "junit5" | |
| test = ("package com.example;\n" + ("import org.junit.jupiter.api.Test;\nimport static org.junit.jupiter.api.Assertions.*;\n" | |
| if junit5 else "import org.junit.Test;\nimport static org.junit.Assert.*;\n") | |
| + "public class CalculatorTest {\n @Test " + ("void" if junit5 else "public void") | |
| + " twice() { assertEquals(4, new Calculator().twice(2)); }\n}\n") | |
| r = j.run(CALC, test, extra={"Test02.java": INV}, source_name="Test01.java") | |
| assert r.compiled, r.compile_output | |
| assert r.passed == r.total == 1 | |
| def test_python_alias_not_collected_by_pytest(tmp_path): | |
| p = get_runner("python") | |
| assert p.alias("test_weather_client.py") is None and p.alias("weather_test.py") is None | |
| assert p.alias("weather.py")[0] == "weather.py" | |
| code = "def add(a, b):\n return a + b\n" | |
| r = p.run(code, "from solution import add\n\ndef test_add():\n assert add(1, 2) == 3\n", | |
| source_name="test_math_utils.py") | |
| assert r.passed == r.total == 1 | |
| def test_typescript_in_js_file_runs_as_typescript(): | |
| ts = "export interface P { id: string }\nexport class T {\n f(raw: any): P { return { id: String(raw) }; }\n}\n" | |
| assert JobRequest(language="javascript", code=ts).language == "typescript" | |
| assert JobRequest(language="javascript", code="export function f(a, b) { return { a: 1 }; }").language == "javascript" | |
| assert JobRequest(language="javascript", code=ts, test_kind="ui").language == "javascript" | |
| assert not looks_typescript("const type = 'x';\nlet y = c ? a : b;\n") | |