Fix noisy tests (#6004)

* Fixes #5570.

The issue is calls to atexit aren't mocked out. During the tests there are many
repeated calls registering functions to be called when the process exits so
when the tests finishes, it prints a ton of output from running those
registered functions. This suppresses that by mocking out atexit.

* Mock at a lower level.

This ensures we don't mess with any other mocks in this test class by mocking
at the lowest level we can. Other tests shouldn't be mocking out specific
internals of functions in other modules, so this should work just fine.
This commit is contained in:
Brad Warren 2018-05-16 06:24:14 -07:00 committed by GitHub
parent 722dac86d5
commit 41e1976c17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -626,7 +626,8 @@ class MainTest(test_util.ConfigTestCase): # pylint: disable=too-many-public-met
toy_stdout = stdout if stdout else six.StringIO()
with mock.patch('certbot.main.sys.stdout', new=toy_stdout):
with mock.patch('certbot.main.sys.stderr') as stderr:
ret = main.main(args[:]) # NOTE: parser can alter its args!
with mock.patch("certbot.util.atexit"):
ret = main.main(args[:]) # NOTE: parser can alter its args!
return ret, toy_stdout, stderr
def test_no_flags(self):