Skip to content

Commit 7cf0998

Browse files
MasloMaslanegeoff128PiotrJuniorjrozek
authored
Add testing information to readme (#10)
* Add testing information to readme * Refactor readme * Example usage in readme * Update README.md Co-authored-by: PiotrJunior <[email protected]> * fixes from PR comments --------- Co-authored-by: Tomasz Kwiatkowski <[email protected]> Co-authored-by: PiotrJunior <[email protected]> Co-authored-by: jrozek <[email protected]>
1 parent 9948d30 commit 7cf0998

File tree

3 files changed

+86
-2
lines changed

3 files changed

+86
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ build
66
.idea
77
__pycache__
88
tests/test_django/db.sqlite3
9+
htmlcov
910

1011
# pytest-cov
1112
.coverage*
1213
coverage.xml
14+
15+
# macOS
16+
.DS_Store

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,81 @@
1+
from sio3pack.graph import GraphOperation
2+
13
# SIO3Pack
4+
5+
## Example usage
6+
7+
### In OIOIOI
8+
9+
```python
10+
# Package unpacking
11+
import sio3pack, sio3workers
12+
from django.conf import settings
13+
package = sio3pack.from_file(path_to_package, django_settings=settings)
14+
graph_op: GraphOperation = package.get_unpack_graph()
15+
results = sioworkers.run(graph_op)
16+
graph_op.return_results(results)
17+
package.save_to_db(problem_id=1)
18+
```
19+
20+
### Locally (for example `sinol-make`)
21+
22+
```python
23+
import sio3pack, sio3workers.local
24+
package = sio3pack.from_file(path_to_package)
25+
graph_op: GraphOperation = package.get_unpack_graph()
26+
results = sio3workers.local.run(graph_op)
27+
graph_op.return_results(results)
28+
```
29+
30+
---
31+
32+
## Development
33+
34+
### Test without django support
35+
36+
Install the package in editable mode and make sure that `django` and
37+
`pytest-django` are not installed.
38+
39+
```bash
40+
pip install -e ".[tests]"
41+
pip uninstall django pytest-django
42+
```
43+
44+
Then follow the instructions in
45+
[General testing information](#general-testing-information).
46+
47+
48+
### Test with django support
49+
50+
Install the package in editable mode along with Django dependencies:
51+
52+
```bash
53+
pip install -e ".[django,tests,django_tests]"
54+
```
55+
56+
Then follow the instructions in
57+
[General testing information](#general-testing-information).
58+
59+
60+
### General testing information
61+
62+
Run the tests with `pytest` in the root directory of
63+
the repository.
64+
65+
```bash
66+
pytest -v
67+
```
68+
69+
To run tests in parallel, use the following command.
70+
71+
```bash
72+
pytest -v -n auto
73+
```
74+
75+
To run coverage tests, use the following command.
76+
77+
```bash
78+
pytest -v --cov=sio3pack --cov-report=html
79+
```
80+
81+
The coverage report will be generated in the file `htmlcov/index.html`.

src/sio3pack/graph/graph_op.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def __init__(self, graph: Graph, return_results: bool = False, return_func: call
1515
results, if return_results is True.
1616
"""
1717
self.graph = graph
18-
self.return_results = return_results
18+
self.should_return = return_results
1919
self.return_func = return_func
2020

2121
def return_results(self, data: dict):
22-
if self.return_func:
22+
if self.return_func and self.should_return:
2323
return self.return_func(data)

0 commit comments

Comments
 (0)