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

Python unit test cleanup #1463

Closed
halfflat opened this issue Mar 25, 2021 · 1 comment · Fixed by #1693
Closed

Python unit test cleanup #1463

halfflat opened this issue Mar 25, 2021 · 1 comment · Fixed by #1693
Labels
code quality python test Unit tests, validation tests, test coverage, test quality.

Comments

@halfflat
Copy link
Contributor

Putting coverage aside, there is a lot of boilerplate code in our Python unit test suite, and the tests all seem to use unittest.makeSuite, which is undocumented and deprecated.

Let's:

  • Replace the use of makeSuite.
  • See if the runner code quoted below can be made less horribly redundant.
  • Have a look at any other clean ups of the scaffolding?
try:
    import options
    import test_contexts
    import test_domain_decomposition
    # […]
except ModuleNotFoundError:
    from test import options
    from test.unit import test_contexts
    from test.unit import test_domain_decompositions
    # […]
test_modules = [\
    test_contexts,\
    test_domain_decompositions,\
    # […]
]

def suite():
    loader = unittest.TestLoader()
    suites = []
    for test_module in test_modules:
        test_module_suite = test_module.suite()
        suites.append(test_module_suite)

    suite = unittest.TestSuite(suites)
    return suite
@halfflat halfflat added code quality python test Unit tests, validation tests, test coverage, test quality. labels Mar 25, 2021
@Helveg
Copy link
Collaborator

Helveg commented Sep 27, 2021

Continuing here then, yes, it's pretty terrible! I don't think arbor has a need that unittest cannot meet. Unless there's someone who is really obsessed with fancy fixtures.

I can look into dropping all of the boilerplate in favor of python -m unittest discover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality python test Unit tests, validation tests, test coverage, test quality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants