Skip to content

Commit 5c26b42

Browse files
authored
ci: Add pytest coverage checks (#244)
* Add pytest coverage checks - Add pytest-coverage to dev_requirements - Move tests to lms root directory - Add integration with codecov
1 parent 58479ab commit 5c26b42

34 files changed

+37
-32
lines changed

.flake8

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[flake8]
22
per-file-ignores =
33
lms/lmstests/sandbox/linters/defines.py:E501
4-
lms/tests/test_exercise_unit_tests.py:Q001
5-
lms/tests/test_html_linter.py:Q001,E501
6-
lms/tests/test_css_linter.py:Q001,E501
7-
lms/tests/test_extractor.py:W293
8-
lms/tests/samples/code2.py:E999,W293,W391,E227,E225,E228
4+
tests/test_exercise_unit_tests.py:Q001
5+
tests/test_html_linter.py:Q001,E501
6+
tests/test_css_linter.py:Q001,E501
7+
tests/test_extractor.py:W293
8+
tests/samples/code2.py:E999,W293,W391,E227,E225,E228
99
ignore=I100,S101,I201,W503

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ Procfile text
269269
# Ignore files (like .npmignore or .gitignore)
270270
*.*ignore text
271271

272-
lms/tests/samples/* text=false
272+
tests/samples/* text=false
273273

274274
#
275275
# Exclude files from exporting

.github/workflows/cr-checks.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,8 @@ jobs:
3232
run: |
3333
export PYTHONPATH=`pwd`
3434
export PATH=/opt/vnu/vnu-runtime-image/bin:$PATH
35-
pytest -vvv --junitxml=junit/test-results.xml
35+
pytest -vvv --junitxml=junit/test-results.xml --cov-report=xml --cov=lms ./tests
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v1.0.13
38+
with:
39+
file: coverage.xml

dev_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
debugpy==1.0.0rc2
22
ipdb==0.13.3
3+
pytest-cov==2.10.1
34
pytest-env==0.6.2
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Upload 3141
2-
3-
"""Normal exercise"""
1+
# Upload 3141
2+
3+
"""Normal exercise"""
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
2-
3-
# Upload 3141
4-
5-
Normal exercise
6-
להלהלה
7-
8-
9-
קצת מילים, @!%^%^& וסימנים מוזרים
10-
רווח בסוף yay
11-
12-
1+
2+
3+
# Upload 3141
4+
5+
Normal exercise
6+
להלהלה
7+
8+
9+
קצת מילים, @!%^%^& וסימנים מוזרים
10+
רווח בסוף yay
11+
12+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lms/tests/test_auto_solution_solver.py renamed to tests/test_auto_solution_solver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from lms.lmsdb import models
44
from lms.lmstests.public.identical_tests import tasks
55
from lms.models import notifications
6-
from lms.tests import conftest
6+
from tests import conftest
77

88

99
SOME_CODE = "print('Hello Word')"

lms/tests/test_config_migrator.py renamed to tests/test_config_migrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import shutil
44

55
from lms.utils import config_migrator
6-
from lms.tests import conftest
6+
from tests import conftest
77

88

99
CONFIG_EXAMPLE_FILE = pathlib.Path(conftest.SAMPLES_DIR) / 'config.py.example'
File renamed without changes.

lms/tests/test_download_file.py renamed to tests/test_download_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from lms.extractors.base import File
1010
from lms.lmsdb.models import Exercise, User
1111
from lms.lmsweb import routes
12-
from lms.tests import conftest
1312
from lms.utils import hashing
13+
from tests import conftest
1414

1515

1616
DOWNLOAD_FILE = os.path.join(conftest.SAMPLES_DIR, 'download_test.zip')

lms/tests/test_exercise_unit_tests.py renamed to tests/test_exercise_unit_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from lms.lmstests.public.unittests import executers
88
from lms.lmstests.public.unittests import tasks
99
from lms.models import notifications
10-
from lms.tests import conftest
10+
from tests import conftest
1111

1212

1313
STUDENT_CODE = """
File renamed without changes.

lms/tests/test_extractor.py renamed to tests/test_extractor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import lms.extractors.base as extractor
1010
import lms.extractors.ziparchive as zipfilearchive
1111
from lms.lmsdb.models import User
12-
from lms.tests import conftest
13-
from lms.tests.conftest import SAMPLES_DIR
12+
from tests import conftest
13+
from tests.conftest import SAMPLES_DIR
1414

1515

1616
class TestExtractor:
File renamed without changes.

lms/tests/test_flask_limiter.py renamed to tests/test_flask_limiter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from lms.tests import conftest
21
from lms.lmsdb.models import User
32
from lms.lmsweb import webapp
3+
from tests import conftest
44

55

66
class TestLimiter:

lms/tests/test_html_escaping.py renamed to tests/test_html_escaping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from flask import json
22

33
from lms.lmsdb.models import Solution, User
4-
from lms.tests import conftest
4+
from tests import conftest
55

66

77
USER_COMMENT_BEFORE_ESCAPING = '<html><body><p>Welcome "LMS"</p></body></html>'
File renamed without changes.

lms/tests/test_notifications.py renamed to tests/test_notifications.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from lms.lmsdb.models import Exercise, Notification, Solution, User
88
from lms.models import notifications, solutions
9-
from lms.tests import conftest
9+
from tests import conftest
1010

1111

1212
class TestNotification:

lms/tests/test_solutions.py renamed to tests/test_solutions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from lms.lmstests.public.general import tasks as general_tasks
77
from lms.lmsweb import routes
88
from lms.models import notifications, solutions
9-
from lms.tests import conftest
9+
from tests import conftest
1010

1111

1212
celery_async = (
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)