SystemExit error in unittest and AssertionError in coverage with multiprocessing

Issue #372 closed
Abdeali Kothari created an issue

I am calling my test using subprocess.Popen(["python", "-m", "coverage", "run", "ServerTest"] and inside I am spawning a subprocess to create a server to test on. I need to enable coverage on the subprocess spawned. The subprocess is spawned using subprocess.Popen(["python", "-m", "coverage", "run", __file__, "server"]) - so, it just adds an argument to the same file.

I added the env variable COVERAGE_PROCESS_START and called coverage.process_startup() inside the but I am getting the following errors :

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/coverage/", line 575, in do_execute
    self.run_python_file(filename, args)
  File "/usr/lib/python3/dist-packages/coverage/", line 104, in run_python_file
    exec_code_object(code, main_mod.__dict__)
  File "/usr/lib/python3/dist-packages/coverage/", line 93, in exec_code_object
    exec(code, global_map)
  File "/mnt/data/gnome/jhbuild/other-installs/coala/coalib/tests/output/dbus/", line 103, in <module>
  File "/usr/lib/python3.4/unittest/", line 93, in __init__
  File "/usr/lib/python3.4/unittest/", line 246, in runTests
    sys.exit(not self.result.wasSuccessful())
SystemExit: False

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.4/", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.4/", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/coverage/", line 4, in <module>
  File "/usr/lib/python3/dist-packages/coverage/", line 721, in main
    status = CoverageScript().command_line(argv)
  File "/usr/lib/python3/dist-packages/coverage/", line 438, in command_line
    self.do_execute(options, args)
  File "/usr/lib/python3/dist-packages/coverage/", line 580, in do_execute
  File "/usr/lib/python3/dist-packages/coverage/", line 410, in stop
  File "/usr/lib/python3/dist-packages/coverage/", line 294, in stop
    assert self._collectors[-1] is self

I was able to suppress the first error by using the exit kwarg : unittest.main(exit=False) but I cannot figure out the second error about AssertionError.

Note : The python3 -m coverage ServerTest server has a Glib loop running inside it - it's basically a dbus server.

Edit: My codes can be found at it can be run using ./ -c -t DbusServerTest

Comments (6)

  1. Ned Batchelder repo owner

    Sorry for the long delay in looking into this. Your GitHub branch is gone. Have you fixed this problem?

  2. Abdeali Kothari reporter

    Hi Loic, Thanks for looking into this but I think I should close this because we completely revamped the testing framework and use pytest. Plus the code which had the issue has been removed now.

    Closing this issue as it does not affect me anymore.

  3. Log in to comment