Skip to content

Commit 23a7588

Browse files
committed
Merge branch 'dev-tests' into dev-tests-plat-143-modernpy
2 parents bfe3608 + 90d1b5d commit 23a7588

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

LNX-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ services:
4545
interval: 15s
4646
fakeservices.datajoint.io:
4747
<<: *net
48-
image: datajoint/nginx:v0.2.7
48+
image: datajoint/nginx:v0.2.8
4949
environment:
5050
- ADD_db_TYPE=DATABASE
5151
- ADD_db_ENDPOINT=db:3306

docs/src/develop.md

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

4040
- Entire test suite:
4141
```
42-
nosetests -vw tests_old
42+
pytest -sv --cov-report term-missing --cov=datajoint tests
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-
> ```
4844

4945
- A single functional test:
5046
```
51-
nosetests -vs --tests=tests_old.test_external_class:test_insert_and_fetch
47+
pytest -sv tests/test_connection.py::test_dj_conn
5248
```
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-
> ```
5749
- A single class test:
5850
```
59-
nosetests -vs --tests=tests_old.test_fetch:TestFetch.test_getattribute_for_fetch1
51+
pytest -sv tests/test_aggr_regressions.py::TestIssue558
6052
```
6153

6254
### Style Tests

tests/test_blob.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import datajoint as dj
23
import timeit
34
import numpy as np
@@ -10,6 +11,13 @@
1011
from .schema import Longblob
1112

1213

14+
@pytest.fixture
15+
def enable_feature_32bit_dims():
16+
dj.blob.use_32bit_dims = True
17+
yield
18+
dj.blob.use_32bit_dims = False
19+
20+
1321
def test_pack():
1422
for x in (
1523
32,
@@ -180,6 +188,8 @@ def test_insert_longblob(schema_any):
180188
assert (Longblob & "id=1").fetch1()["data"].all() == query_mym_blob["data"].all()
181189
(Longblob & "id=1").delete()
182190

191+
192+
def test_insert_longblob_32bit(schema_any, enable_feature_32bit_dims):
183193
query_32_blob = (
184194
"INSERT INTO djtest_test1.longblob (id, data) VALUES (1, "
185195
"X'6D596D00530200000001000000010000000400000068697473007369646573007461736B73007374"
@@ -190,7 +200,6 @@ def test_insert_longblob(schema_any):
190200
"00000041020000000100000008000000040000000000000053007400610067006500200031003000')"
191201
)
192202
dj.conn().query(query_32_blob).fetchall()
193-
dj.blob.use_32bit_dims = True
194203
fetched = (Longblob & "id=1").fetch1()
195204
expected = {
196205
"id": 1,
@@ -211,25 +220,31 @@ def test_insert_longblob(schema_any):
211220
assert fetched["id"] == expected["id"]
212221
assert np.array_equal(fetched["data"], expected["data"])
213222
(Longblob & "id=1").delete()
214-
dj.blob.use_32bit_dims = False
215223

216224

217225
def test_datetime_serialization_speed():
218226
# If this fails that means for some reason deserializing/serializing
219227
# np arrays of np.datetime64 types is now slower than regular arrays of datetime
228+
assert not dj.blob.use_32bit_dims, "32 bit dims should be off for this test"
229+
context = dict(
230+
np=np,
231+
datetime=datetime,
232+
pack=pack,
233+
unpack=unpack,
234+
)
220235

221236
optimized_exe_time = timeit.timeit(
222237
setup="myarr=pack(np.array([np.datetime64('2022-10-13 03:03:13') for _ in range(0, 10000)]))",
223238
stmt="unpack(myarr)",
224239
number=10,
225-
globals=globals(),
240+
globals=context,
226241
)
227242
print(f"np time {optimized_exe_time}")
228243
baseline_exe_time = timeit.timeit(
229244
setup="myarr2=pack(np.array([datetime(2022,10,13,3,3,13) for _ in range (0, 10000)]))",
230245
stmt="unpack(myarr2)",
231246
number=10,
232-
globals=globals(),
247+
globals=context,
233248
)
234249
print(f"python time {baseline_exe_time}")
235250

0 commit comments

Comments
 (0)