Search code examples
python-3.xmutation

Getting Error while running Mutation testing on Python code : AttributeError: 'MutationTestRunnerThread' object has no attribute 'isAlive'


I am working on Python programming Mutation testing using Mut.py. Unit testing is passed and when I run the Mutation testing on command line using the command, I am getting error like this.

C:\Users\pc\Desktop\My_Projects\Calculator01>mut.py --target simpleCalculator.py --unit-test test_simpleCalculator.py --runner pytest --coverage
Traceback (most recent call last):
  File "C:\Users\pc\AppData\Local\Programs\Python\Python39\Scripts\mut.py", line 7, in <module>
    commandline.main(sys.argv)
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\commandline.py", line 10, in main
    run_mutpy(parser)
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\commandline.py", line 61, in run_mutpy
    mutation_controller = build_controller(cfg)
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\commandline.py", line 73, in build_controller
    return controller.MutationController(
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\controller.py", line 60, in __init__
    self.runner = runner_cls(self.test_loader, self.timeout_factor, self.stdout_manager, mutate_covered)
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\test_runners\base.py", line 150, in __init__
    self.init_modules = self.find_init_modules()
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\test_runners\base.py", line 209, in find_init_modules
    test_runner.terminate()
  File "c:\users\pc\appdata\local\programs\python\python39\lib\site-packages\mutpy\utils.py", line 357, in terminate
    if self.isAlive():
**AttributeError: 'MutationTestRunnerThread' object has no attribute 'isAlive'**

Can anyone help?


Solution

  • I recently had the same issue, and here is a quick fix that worked for me:

    • Open utils.py shown in the error message
    • Go to the line "if self.isAlive():", shown in the error message
    • Make the following change: if self.isAlive(): becomes if self.is_alive():

    My computer ran on Windows 10 with python 3.9.0, with mutpy 0.6.1.