Skip to content

Commit a55e8d6

Browse files
authored
Merge pull request #1079 from guzman-raphael/pytest
Initialize `pytest` and convert `test_connection`
2 parents 40a6794 + 7a41e8b commit a55e8d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+451
-247
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ FROM mcr.microsoft.com/devcontainers/python:3.7-bullseye
44
RUN \
55
apt update && \
66
apt-get install bash-completion graphviz default-mysql-client -y && \
7-
pip install flake8 black faker ipykernel nose nose-cov datajoint && \
7+
pip install flake8 black faker ipykernel pytest pytest-cov nose nose-cov datajoint && \
88
pip uninstall datajoint -y
99

1010
ENV DJ_HOST fakeservices.datajoint.io

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ghcr.io/guiyomh/features/vim:0": {}
1717
},
1818
"onCreateCommand": "pip install -e .",
19-
"postStartCommand": "MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml down && MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml up --build --wait",
19+
"postStartCommand": "MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml down && docker volume prune -f && MYSQL_VER=8.0 MINIO_VER=RELEASE.2022-08-11T04-37-28Z docker compose -f local-docker-compose.yml up --build --wait",
2020
"forwardPorts": [
2121
80,
2222
443,

.github/workflows/development.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
--count --max-complexity=62 --max-line-length=127 --statistics
9393
black datajoint --check -v
9494
black tests --check -v
95+
black tests_old --check -v
9596
publish-docs:
9697
if: |
9798
github.event_name == 'push' &&

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,11 @@
1111
"[markdown]": {
1212
"editor.defaultFormatter": "disable"
1313
},
14+
"[yaml]": {
15+
"editor.defaultFormatter": "disable"
16+
},
17+
"[dockercompose]": {
18+
"editor.defaultFormatter": "disable"
19+
},
1420
"files.autoSave": "off"
1521
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Changed - `.data` method to `.stream` in the `get()` method for S3 (external) objects PR [#1085](https://github.com/datajoint/datajoint-python/pull/1085)
99
- Fixed - Docs to rename `create_virtual_module` to `VirtualModule`
1010
- Added - Skeleton from `datajoint-company/datajoint-docs` repository for docs migration
11+
- Added - Initial `pytest` for `test_connection`
1112

1213
### 0.14.0 -- Feb 13, 2023
1314
- Added - `json` data type ([#245](https://github.com/datajoint/datajoint-python/issues/245)) PR [#1051](https://github.com/datajoint/datajoint-python/pull/1051)

LNX-docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ services:
8989
pip install --user nose nose-cov
9090
pip install -e .
9191
pip list --format=freeze | grep datajoint
92-
nosetests -vsw tests --with-coverage --cover-package=datajoint
92+
pytest -sv --cov-report term-missing --cov=datajoint tests
93+
nosetests -vsw tests_old --with-coverage --cover-package=datajoint
9394
# ports:
9495
# - "8888:8888"
9596
user: ${HOST_UID}:anaconda

datajoint/admin.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
logger = logging.getLogger(__name__.split(".")[0])
99

1010

11-
def set_password(
12-
new_password=None, connection=None, update_config=None
13-
): # pragma: no cover
11+
def set_password(new_password=None, connection=None, update_config=None):
1412
connection = conn() if connection is None else connection
1513
if new_password is None:
1614
new_password = getpass("New password: ")
@@ -28,7 +26,7 @@ def set_password(
2826
config.save_local(verbose=True)
2927

3028

31-
def kill(restriction=None, connection=None, order_by=None): # pragma: no cover
29+
def kill(restriction=None, connection=None, order_by=None):
3230
"""
3331
view and kill database connections.
3432

datajoint/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ def conn(
120120
host = host if host is not None else config["database.host"]
121121
user = user if user is not None else config["database.user"]
122122
password = password if password is not None else config["database.password"]
123-
if user is None: # pragma: no cover
123+
if user is None:
124124
user = input("Please enter DataJoint username: ")
125-
if password is None: # pragma: no cover
125+
if password is None:
126126
password = getpass(prompt="Please enter DataJoint password: ")
127127
init_fun = (
128128
init_fun if init_fun is not None else config["connection.init_function"]

datajoint/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def load(self, force=True):
127127
self.add_edge(fk["referenced_table"], alias_node, **props)
128128
self.add_edge(alias_node, fk["referencing_table"], **props)
129129

130-
if not nx.is_directed_acyclic_graph(self): # pragma: no cover
130+
if not nx.is_directed_acyclic_graph(self):
131131
raise DataJointError("DataJoint can only work with acyclic dependencies")
132132
self._loaded = True
133133

docs/src/develop.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,24 @@ The following will verify there are no regression errors by running our test sui
3939

4040
- Entire test suite:
4141
```
42-
nosetests -vw tests
42+
nosetests -vw tests_old
4343
```
44+
> Note: We are in the process of upgrading to `pytest` tests. To run those, use:
45+
> ```
46+
> pytest -sv --cov-report term-missing --cov=datajoint tests
47+
> ```
48+
4449
- A single functional test:
4550
```
46-
nosetests -vs --tests=tests.test_external_class:test_insert_and_fetch
51+
nosetests -vs --tests=tests_old.test_external_class:test_insert_and_fetch
4752
```
53+
> Note: We are in the process of upgrading to `pytest` tests. To run those, use:
54+
> ```
55+
> pytest -sv tests/test_connection.py::test_dj_conn
56+
> ```
4857
- A single class test:
4958
```
50-
nosetests -vs --tests=tests.test_fetch:TestFetch.test_getattribute_for_fetch1
59+
nosetests -vs --tests=tests_old.test_fetch:TestFetch.test_getattribute_for_fetch1
5160
```
5261
5362
### Style Tests

0 commit comments

Comments
 (0)