Skip to content

Commit abc47b7

Browse files
Stefan Majoorknokko
authored andcommitted
Update test script to not use setuptools, since setuptools test is deprecatd
1 parent 601c285 commit abc47b7

File tree

5 files changed

+24
-37
lines changed

5 files changed

+24
-37
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ FROM python:3.9
22
ENV PYTHONUNBUFFERED 1
33
RUN mkdir /binder
44
WORKDIR /binder
5-
ADD . /binder
5+
ADD setup.py .
6+
ADD README.md .
7+
RUN pip install -e .[test]

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ Code Yellow backend framework for SPA webapps with REST-like API.
99

1010
## Running the tests
1111

12-
Run with docker `docker compose run binder ./setup.py test` (but you may need to run `docker compose build db binder` first)
13-
- Access the test database directly by with `docker compose run db psql -h db -U postgres`.
12+
- Run with `./test`
13+
- Access the test database directly by with `docker compose run --rm db psql -h db -U postgres`.
1414
- It may be possible to recreate the test database (for example when you added/changed models). One way of achieving this is to just remove all the docker images that were build `docker compose rm`. The database will be created during the setup in `tests/__init__.py`.
1515

1616
The tests are set up in such a way that there is no need to keep migration files. The setup procedure in `tests/__init__.py` handles the preparation of the database by directly calling some build-in Django commands.
1717

18-
To only run a selection of the tests, use the `-s` flag like `./setup.py test -s tests.test_some_specific_test`.
18+
To only run a selection of the tests, use the `-k` flag like `./test -k tests.test_some_specific_test`.
1919

2020
## MySQL support
2121

binder/tests_discoverer.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,2 @@
1-
from django.apps import apps
2-
try:
3-
from django.test.runner import is_discoverable
4-
except ImportError:
5-
# Django 4 support
6-
from django.test.runner import try_importing
7-
def is_discoverable(path):
8-
is_importable, _ = try_importing(path)
9-
return is_importable
10-
11-
# This prevents discoverer from loading models and views, which will
12-
# cause all sorts of random failures.
131
def load_tests(loader, tests, pattern):
14-
for app in apps.get_app_configs():
15-
app_path = app.path
16-
test_dir = '{}/tests/'.format(app_path)
17-
try:
18-
if is_discoverable(test_dir):
19-
tests.addTests(loader.discover(test_dir))
20-
except AssertionError:
21-
# This is thrown if the app is loaded from the venv. These can not be tested anyway
22-
pass
23-
24-
return tests
2+
return tests

setup.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
url='https://github.com/CodeYellowBV/django-binder',
2222
author='Marcel Moreaux',
2323
author_email='marcel@codeyellow.nl',
24-
test_suite='tests',
2524
classifiers=[
2625
'Environment :: Web Environment',
2726
'Framework :: Django',
@@ -43,13 +42,15 @@
4342
'requests >= 2.13.0',
4443
'pika == 1.3.2',
4544
],
46-
tests_require=[
47-
'django-hijack >= 2.1.10, < 3.0.0',
48-
(
49-
'mysqlclient >= 1.3.12'
50-
if os.environ.get('BINDER_TEST_MYSQL', '0') == '1' else
51-
'psycopg2 >= 2.7'
52-
),
53-
"openpyxl >= 3.0.0"
54-
],
45+
extras_require={
46+
'test': [
47+
'django-hijack >= 2.1.10, < 3.0.0',
48+
(
49+
'mysqlclient >= 1.3.12'
50+
if os.environ.get('BINDER_TEST_MYSQL', '0') == '1' else
51+
'psycopg2 >= 2.7'
52+
),
53+
"openpyxl >= 3.0.0"
54+
],
55+
}
5556
)

test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e
3+
4+
docker compose build binder
5+
6+
docker compose run --rm binder python -m unittest "$@"

0 commit comments

Comments
 (0)