PLAT-166: Migrate test_schema#1136
Conversation
ethho
commented
Dec 14, 2023
- cp to tests
- nose2pytest test_schema
- Add db_creds_test fixture
- First pass at migrating test_schema
- Mock schema_empty module
- Move call to spawn_missing_classes to test
| user=os.getenv("DJ_TEST_USER", "datajoint"), | ||
| password=os.getenv("DJ_TEST_PASSWORD", "datajoint"), | ||
| ) | ||
|
|
There was a problem hiding this comment.
Another part of the move towards putting these credentials in fixtures.
| for k, v in namespace_dict.items(): | ||
| setattr(module, k, v) | ||
|
|
||
| return module |
There was a problem hiding this comment.
This was an interesting problem. In tests_old/schema_empty.py, spawn_missing_classes relies on the schema.schema (called the schema_any fixture in new tests) being activated on import. Because this is now in the schema_any fixture, we weren't able to create schema_empty.schema the same way in the pytest suite (in pytest, the value of the fixture is only available after everything's been imported). Instead, I used the types.ModuleType to mock a module that mimics the same behavior in tests_old/schema_empty.py.
| definition = """ | ||
| type: varchar(32) # type of cell | ||
| """ | ||
|
|
There was a problem hiding this comment.
A bit inconsistent in the way we add Cell to test_schema, but this is exactly the way it was written in the old tests, so I'm just going to leave it.
|
Merging into |
Clean up modules that were migrated in PRs: datajoint#1136, 1137, 1138, 1139, 1140