-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLAT-107: Clean up #1141
PLAT-107: Clean up #1141
Conversation
Also move table defs to schema_alter module
Clean up modules that were migrated in PRs: datajoint#1136, 1137, 1138, 1139, 1140
No reason for this to be defined in the fixture. Move to the module level to stay consistent.
import datajoint as dj | ||
import inspect | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this schema to a separate module per @A-Baji 's previous suggestion.
|
||
@pytest.fixture | ||
def schema_name(prefix): | ||
return prefix + "_test_custom_datatype" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched this to a fixture, because it uses prefix
which is now also a fixture.
self.insert1(dict(key, crop_image=dict())) | ||
|
||
Crop.populate() | ||
from . import schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from methods to top-level functions.
tests/test_blob.py
Outdated
@@ -207,6 +208,8 @@ def test_insert_longblob(schema_any): | |||
dtype=[("hits", "O"), ("sides", "O"), ("tasks", "O"), ("stage", "O")], | |||
), | |||
} | |||
assert fetched['id'] == expected['id'] | |||
assert np.array_equal(fetched['data'], expected['data']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectively the same logic, but resolves a DeprecationWarning
.
yield Subjects | ||
Subjects.drop() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved Schema
as a module level definition. This keeps it consistent with other schemas in the test suite.
@@ -12,36 +11,41 @@ class NanTest(dj.Manual): | |||
""" | |||
|
|||
|
|||
@pytest.fixture(scope="module") | |||
def schema(connection_test): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to give these fixtures more descriptive and unique names. While reusing the name schema
between test modules technically works, unique names like schema_nan
make it clearer that tests in different modules are using entirely different fixtures.
def setup_class(request, schema): | ||
@pytest.fixture | ||
def arr_a(): | ||
return np.array([0, 1 / 3, np.nan, np.pi, np.nan]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This array is used in multiple tests, so I moved to a fixture in the spirit of DRY.
def trash(schema_any): | ||
return schema.UberTrash() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to conftest.py
cls.ephys = Ephys() | ||
cls.channel = Ephys.Channel() | ||
cls.img = Image() | ||
cls.trash = UberTrash() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setup_class
, these tests use fixtures like subject
and experiment
which are now defined in conftest.py
.
) | ||
from . import PREFIX, CONN_INFO | ||
from .schema_simple import * | ||
from .schema import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More succinct, relatively safe (since we define __all__
in the schema*
modules, and consistent with how we import table definitions elsewhere.
Ensures that dj.blob.use_32bit_dims is turned off even if test_insert_longblob fails.
A possible fix for datajoint#1145.
CI tests that use |
Clean up pytest suite to keep patterns consistent. For instance, aggregate commonly used fixtures in conftest.py