Hey Anvil Team, hope your Thursday is going well!
Recently I ran into an issue trying to automatically discover unit tests on the server side. A hardcoded workaround was suggested, but I still want to have the capability to automatically find my tests.
The current way I’m running the tests (with no auto discovery of test modules):
@anvil.server.callable
def run_tests(verbosity=0):
test_modules = ['ServerModule1']
test = unittest.TestLoader().loadTestsFromNames(test_modules)
unittest.TextTestRunner(stream=sys.stdout, verbosity=verbosity).run(test)
The way I’d like to run the server tests (with module auto discovery, implemented by Anvil)
@anvil.server.callable
def run_tests(verbosity=0):
test_modules = anvil.server.moudles.discover(pattern = "_TestModule")
test = unittest.TestLoader().loadTestsFromNames(test_modules)
unittest.TextTestRunner(stream=sys.stdout, verbosity=verbosity).run(test)
App Clone
https://anvil.works/build#clone:DQZXRKPMNUATUKKM=WAXXIZQMELIHSBXFWKMVVWSW