Skip to content

Commit

Permalink
added pytest runner
Browse files Browse the repository at this point in the history
  • Loading branch information
smythi93 committed Jun 28, 2023
1 parent 8db0358 commit a18ad3a
Show file tree
Hide file tree
Showing 7 changed files with 486 additions and 37 deletions.
109 changes: 76 additions & 33 deletions BugsInPy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,31 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "6fe1d278",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting whatthepatch\n",
" Downloading whatthepatch-1.0.5-py3-none-any.whl (11 kB)\n",
"Installing collected packages: whatthepatch\n",
"Successfully installed whatthepatch-1.0.5\n",
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.1.2\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [
"!pip install whatthepatch"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "71944b13-ca1f-4f5b-b1dd-7f0447e01626",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -54,7 +78,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 6,
"id": "7a4db981-8306-4bb0-88d8-5b3f711adaee",
"metadata": {},
"outputs": [],
Expand All @@ -65,7 +89,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 7,
"id": "6d269bfe-e9eb-43ac-977f-6bed9080173e",
"metadata": {},
"outputs": [],
Expand All @@ -76,7 +100,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 8,
"id": "41cfb43a-fa07-49d4-82e3-b1a0cb04971f",
"metadata": {},
"outputs": [],
Expand All @@ -90,7 +114,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"id": "84c154e6-9bd3-4a46-9604-73a895457f45",
"metadata": {},
"outputs": [],
Expand All @@ -104,17 +128,17 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 10,
"id": "54609932-e26f-4fd1-86b6-b6e49fa78fde",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/home/marius/sflkit'"
"'/Users/marius/Desktop/work/projects/sflkit'"
]
},
"execution_count": 6,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -126,17 +150,17 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 11,
"id": "93d35204-e3a9-4911-a7cf-a588d08fc2ef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/home/marius/sflkit/events'"
"'/Users/marius/Desktop/work/projects/sflkit/events'"
]
},
"execution_count": 7,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -148,7 +172,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"id": "deb300c5-7fd1-4ada-9198-566cdd859b61",
"metadata": {},
"outputs": [],
Expand All @@ -167,7 +191,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 13,
"id": "106b4a86-48a2-46b1-94fe-e447df2b7647",
"metadata": {},
"outputs": [],
Expand All @@ -187,7 +211,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 14,
"id": "cb6dc70f-82cc-4475-9cbe-3d481e914cea",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -215,7 +239,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 15,
"id": "65b9d0a4-2d20-4326-88a2-8a7a6a9ee8f2",
"metadata": {},
"outputs": [],
Expand All @@ -227,18 +251,18 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 16,
"id": "37e38835-1276-4db0-9a64-41d3e13df982",
"metadata": {},
"outputs": [],
"source": [
"excluded_subjects = [matplotlib, pandas, spacy]\n",
"max_bugs_per_subject = 3"
"max_bugs_per_subject = 500"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 17,
"id": "ce05a37b-ae11-4009-9e48-d1a5b65ff51a",
"metadata": {},
"outputs": [],
Expand All @@ -249,7 +273,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 18,
"id": "362b469d-6c69-4642-8932-a5ea97873716",
"metadata": {},
"outputs": [],
Expand All @@ -265,7 +289,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 19,
"id": "b67456e2-3039-4a4d-a45c-bc9c40d3583d",
"metadata": {},
"outputs": [],
Expand All @@ -275,7 +299,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 20,
"id": "97fb587c-8706-4436-94f9-7ff3dcd79e4b",
"metadata": {},
"outputs": [],
Expand All @@ -291,7 +315,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 21,
"id": "f832b7ac-1b57-4c42-acf3-c05e2796850e",
"metadata": {},
"outputs": [],
Expand All @@ -302,7 +326,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 22,
"id": "4d2c4307-626c-4c7c-8494-d641fbe5cfa0",
"metadata": {},
"outputs": [],
Expand All @@ -318,7 +342,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 23,
"id": "a02a4869-32d7-4e92-bd5a-7651820f8332",
"metadata": {},
"outputs": [],
Expand All @@ -331,7 +355,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 24,
"id": "9dea83dd-812b-43d7-8579-7963a3d6e6cf",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -359,7 +383,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 25,
"id": "21c43449-662d-42c9-b8e4-2ad5099948b9",
"metadata": {},
"outputs": [],
Expand All @@ -374,7 +398,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 26,
"id": "8fcfecfb-ddd0-4173-9b87-1da35a89ff87",
"metadata": {},
"outputs": [],
Expand All @@ -386,7 +410,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 27,
"id": "1cf603b1-a683-4d47-8fe9-bb461722548c",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -467,7 +491,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 28,
"id": "d6e48520-de25-44aa-8e80-6f6ab1a6f086",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -503,7 +527,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 29,
"id": "d22a6a38-393a-4e91-8f0a-fa513a87d37f",
"metadata": {},
"outputs": [],
Expand All @@ -516,10 +540,29 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 30,
"id": "7ddd63f4-5d9b-46e1-b1ad-e6bbe630cb6b",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"pytest did not generate file\n"
]
},
{
"ename": "AssertionError",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[30], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39massert\u001b[39;00m verify_correct_version(test_project, test_bug_id, test_test_file)\n",
"\u001b[0;31mAssertionError\u001b[0m: "
]
}
],
"source": [
"assert verify_correct_version(test_project, test_bug_id, test_test_file)"
]
Expand Down Expand Up @@ -2208,7 +2251,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.10"
"version": "3.10.4"
}
},
"nbformat": 4,
Expand Down
13 changes: 13 additions & 0 deletions resources/subjects/tests/test_runner/middle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def middle(x, y, z):
m = z
if y < z:
if x < y:
m = y
elif x < z:
m = y # bug
else:
if x > y:
m = y
elif x > z:
m = x
return m
13 changes: 13 additions & 0 deletions resources/subjects/tests/test_runner/tests/test_middle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import unittest
from middle import middle


class MiddleTests(unittest.TestCase):
def test_213(self):
self.assertEqual(middle(2, 1, 3), 2)

def test_321(self):
self.assertEqual(middle(3, 2, 1), 2)

def test_312(self):
self.assertEqual(middle(3, 1, 2), 2)
4 changes: 3 additions & 1 deletion src/sflkit/runners/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import enum

from sflkit.runners.run import Runner, VoidRunner
from sflkit.runners.run import Runner, VoidRunner, PytestRunner, UnittestRunner


class RunnerType(enum.Enum):
def __init__(self, runner: Runner):
self.runner = runner

VOID_RUNNER = VoidRunner
PYTEST_RUNNER = PytestRunner
UNITTEST_RUNNER = UnittestRunner
Loading

0 comments on commit a18ad3a

Please sign in to comment.