From: Richard Si <63936253+ichard26@users.noreply.github.com> Date: Sat, 2 Oct 2021 23:37:32 +0000 (-0400) Subject: MNT: remove unnecessary test deps + some refactoring (GH-2510) X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/3500e1cda5bef73ddc7eaf79be6c67c918738936?ds=sidebyside;hp=3500e1cda5bef73ddc7eaf79be6c67c918738936 MNT: remove unnecessary test deps + some refactoring (GH-2510) The main goals of this commit include: * improving consistency on how strict the test suite is -- Jelle has seen cases where a test did not fail to an incomplete test setup even though it should've * simplifying tests for both ease of creation and reading via parametrization and helpers * reorganizing the test suite by grouping more tests * dropping test suite dependencies that aren't strictly necessary The test suite could definitely do with more refactoring, but this is a good first pass. Anyway it would've gotten too big to review effectively if I did continue on this PR. Commit history before squash merge: * Drop parameterized dep and refactor format tests Since the test suite is already using pytest-only features we can drop the parameterized test dependency in favour of pytest's own offering. I also added an utility function called assert_format that makes it even easier to verify Black formats some code correctly. We already have great tooling if the case is very simple in test_format.py but any sort of complication makes it hard to use. Also if you're writing a non-standard test case, you have to be careful to include all of the steps so issues don't go undetected. assert_format aims to 1) improve consistency, 2) avoid wasted CPU cycles, and 3) avoid logical errors that hide issues. Finally, quite a few tests were either moved and/or simplified with the new setup. * Move file collection tests * Add assert_collected_sources helper function Testing source collection involves a lot of repetitive boilerplate, something that black.files.get_sources's signature does not help with. So to cut down on boilerplate like `report=black.Report()` I added a convenience function to tests/test_black.py which wraps black.get_sources. Its signature is designed to be much more lax to make it much easier to use. Somehow this leads to cutting 100 lines! Also IMO the test cases are much easier to read since it's more declarative than really procedural now. * Run isort on some test files * Move cache tests * Use pytest-style asserts & add parametrization * Drop now unnecessary test dependencies *pytest-cases might be interesting for further refactoring but I haven't been able to wrap my head around it for the time being. We can always revisit anyway. ---