Skip to content

Commit

Permalink
test: use pytest
Browse files Browse the repository at this point in the history
setup.py test is deprecated, switch to pytest.

Also fix some tests that apparently weren't being run.
  • Loading branch information
pefoley2 committed May 30, 2021
1 parent a5503f1 commit cc7c630
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Ion.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ deploy
fabfile.py
manage.py
pyproject.toml
pytest.ini
requirements.txt
setup.py
.dependabot/config.yml
Expand Down
9 changes: 3 additions & 6 deletions ci/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ env:
pip install -U pip setuptools
pip install -U \
flake8 pylint pylint-django pylint-plugin-utils isort~=4.3 black==20.8b1 autopep8 \
coverage coveralls pyyaml
coverage coveralls pyyaml pytest-django
pip install -U -r requirements.txt
echo "PATH=$PATH" >> $GITHUB_ENV
Expand Down Expand Up @@ -134,10 +134,7 @@ jobs:
- *copy_secret

- name: Regenerate workflow YAML file and check for changes
run: |
set -e
pip install pyyaml
./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py
run: ./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py

# Build docs/sources
- name: Build docs
Expand Down Expand Up @@ -239,7 +236,7 @@ jobs:

# Tests
- name: Run tests
run: coverage run ./setup.py test
run: coverage run python -m pytest
- name: Migrate database
run: coverage run -a ./manage.py migrate
- name: Collect static files
Expand Down
4 changes: 2 additions & 2 deletions intranet/apps/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def test_api_eighth_signup_list(self):

def test_api_bus_list(self):
self.make_token()
route = Route.objects.create(route_name="JT-001", bus_number="JT-001")
route = Route.objects.create(route_name="JT-01", bus_number="JT-01")
response = self.client.get(reverse("api_bus_list"), HTTP_AUTHORIZATION=self.auth)

self.assertEqual(response.status_code, 200)
Expand All @@ -517,7 +517,7 @@ def test_api_bus_list(self):

def test_api_bus_detail(self):
self.make_token()
route_1 = Route.objects.create(route_name="JT-001", bus_number="JT-001")
route_1 = Route.objects.create(route_name="JT-01", bus_number="JT-01")
response = self.client.get(reverse("api_bus_detail", args=[route_1.pk]), HTTP_AUTHORIZATION=self.auth)

self.assertEqual(response.status_code, 200)
Expand Down
4 changes: 2 additions & 2 deletions intranet/apps/bus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_bus(self):
m.assert_called()

def test_routes(self):
route = Route.objects.get_or_create(route_name="JT-101", bus_number="JT-101")[0]
route = Route.objects.get_or_create(route_name="JT-01", bus_number="JT-01")[0]
route.status = "a"
route.space = "_1"
route.save()
Expand All @@ -47,7 +47,7 @@ def test_routes(self):
self.assertEqual(route.space, "")

def test_route_representation(self):
route = Route.objects.get_or_create(route_name="JT-101", bus_number="JT-101")[0]
route = Route.objects.get_or_create(route_name="JT-01", bus_number="JT-01")[0]
route_str = str(route)

self.assertEqual(route.route_name, route_str)
4 changes: 2 additions & 2 deletions intranet/apps/events/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def test_add_event(self):
"location": "Location",
"scheduled_activity": "",
"announcement": "",
"groups": 1,
"groups": [],
"show_attending": "on",
"show_on_dashboard": "on",
"category": "sports",
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_modify_event(self):
"location": "New location",
"scheduled_activity": "",
"announcement": "",
"groups": 1,
"groups": [],
"show_attending": "on",
"show_on_dashboard": "on",
"category": "sports",
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
DJANGO_SETTINGS_MODULE = intranet.settings
python_files = tests.py test_*.py

0 comments on commit cc7c630

Please sign in to comment.