Skip to content
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

Fix Unit Tests #88

Merged
merged 26 commits into from
Jun 6, 2024
Merged

Fix Unit Tests #88

merged 26 commits into from
Jun 6, 2024

Conversation

atspaeth
Copy link
Member

@atspaeth atspaeth commented May 23, 2024

I noticed none of the unit tests were executing in CI because pytest looks at /tests, not /src. This PR is about migrating them back in so they run again, except analysis, which is going to be addressed by #87.

State of Tests

The tests all pass locally (Linux, Python 3.10, 3.11, and 3.12), but in CI on Ubuntu/Mac,

  • Some of the messaging-related tests fail nondeterministically.
  • One memoize_s3 test often fails, maybe due to relying on undefined behavior.
  • The coverage report fails to upload to wherever it's supposed to go. (Error: Codecov token not found., with a log line mentioning not finding a config.)

There are also some Windows-specific failures in CI, which I haven't tried reproducing locally:

  • Several tests fail because they can't open directories, which is probably about path separators. (test_read_data_maxwell_v2_format, TestMemoizeS3, and SmartOpenTestCase::test_local_path_endpoint)
  • Some ephys datasets tests fail with (PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\test_cache_eyh8it4l\\cache.db')

Changes

CI and Tests

  • Move all the tests and associated test data (other than analysis) to tests/
  • Fix the CI running triple tests (Redundant CI runs #56).
  • Fix a newly discovered bug in map2() with no kwargs
  • Get AWS credentials file into CI environment.
  • Add the optional dependency joblib (for memoize_s3) to dev extra

Main Library

  • Fix a newly discovered bug in map2() with no kwargs
  • Clean up unused imports and commented-out code across several files
  • Delete braingeneers/data/datasets.py, which was "deprecated" but also unimportable.

atspaeth added 9 commits May 23, 2024 09:50
Fix having removed the test_ prefix from all of them, which prevented
pytest from detecting them. Now `pytest -vv` at project root actually
runs all the unit tests.

Also fix a line in pyproject.toml that was supposed to ignore
any DeprecationWarning generated by the tests.
Fix #56

There was a matrix entry `experimental` with the values `[false, false,
true]`, which meant every unit test was run 3 times changing only that
one flag. It looks like the intention was to just run Windows tests with
`continue-on-error`, but I just set that flag for all the runs for now.
The tests are still pretty broken anyway.
atspaeth added 2 commits May 23, 2024 22:53
It used to just zip the args and kwargs together, which led to mapping
over nothing when args were provided and kwargs defaulted to [].
@atspaeth atspaeth marked this pull request as ready for review May 24, 2024 17:26
@atspaeth atspaeth linked an issue May 24, 2024 that may be closed by this pull request
@atspaeth atspaeth requested a review from DailyDreaming May 25, 2024 01:05
Copy link
Member

@DailyDreaming DailyDreaming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, although a lot of the changes are linting or style changes, which we might want to enforce in a future PR.

I've added decorators to skip failing tests, conditionally failing tests on Windows, and retry decorators for flaky tests. I'll make these into their own issues and they can be resolved and fixed incrementally in future PRs.

Right now this is great to have the testing in, plus some of the clean up. Thanks for doing this!

@DailyDreaming DailyDreaming merged commit 0d8d9e4 into master Jun 6, 2024
7 checks passed
@DailyDreaming DailyDreaming deleted the fix-tests branch June 6, 2024 23:49
atspaeth added a commit that referenced this pull request Jun 7, 2024
* Move test files to tests/

* Delete configure test that no longer makes sense.

* Fix smart_open test by updating assertEqual() method name

* Fix memoize, common_utils, mmap by updating import paths

* Fix path to test maxwell metadata

* Remove generated _version file from git

* Make pytest actually run the tests

Fix having removed the test_ prefix from all of them, which prevented
pytest from detecting them. Now `pytest -vv` at project root actually
runs all the unit tests.

Also fix a line in pyproject.toml that was supposed to ignore
any DeprecationWarning generated by the tests.

* Ignore warnings for tests loading non-row-major datasets

* Remove "deprecated" file that couldn't even be imported

* Make joblib a dev dependency so memoize_s3 tests in CI

* Remove redundant CI runs

Fix #56

There was a matrix entry `experimental` with the values `[false, false,
true]`, which meant every unit test was run 3 times changing only that
one flag. It looks like the intention was to just run Windows tests with
`continue-on-error`, but I just set that flag for all the runs for now.
The tests are still pretty broken anyway.

* Remove dead code, deprecate unusable functions

* Clean more dead code in messages

* Normalize unit test formatting

* Add credentials as a GitHub secret

* Fix common_utils.map2() when no kwargs provided

It used to just zip the args and kwargs together, which led to mapping
over nothing when args were provided and kwargs defaulted to [].

* Does bash fix CI on windows?

* Make memoize_s3 transform \ into / for Windows

* Skip broken tests.

* Skip tests that break only on CI (parallelism?).

* Skip Windows-failing tests conditionally.

* Mark flaky test.

* Mark another flaky test.

* Hammer the nail in place.

* Actually skip the memoize test.

* Mark more flakes.

---------

Co-authored-by: DailyDreaming <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundant CI runs
2 participants