Python coverage crashing when using unittest.mockCalling an external command in PythonWhat are metaclasses in Python?Is there a way to run Python on Android?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

How to emphasise the insignificance of someone/thing – besides using "klein"

GDPR: What happens to deleted contacts re-entered through imports

Why does matter stay collapsed in the core, following a supernova explosion?

How to respond to Brand identity Objections from small business owners?

Pen test results for web application include a file from a forbidden directory that is not even used or referenced

How to determine algebraically whether an equation has an infinite solutions or not?

Which meaning of "must" does the Slow spell use?

Notice period 60 days but I need to join in 45 days

Can I get a PhD for developing an educational software?

How to force GCC to assume that a floating-point expression is non-negative?

How much does Commander Data weigh?

Counting the triangles that can be formed from segments of given lengths

According to UK government, Parliament cannot stop a no-deal Brexit: Could this also be used to push through the agreement agreed by Theresa May?

Can a DM change an item given by another DM?

Shift lens vs move body?

Find most "academic" implementation of doubly linked list

rationalizing sieges in a modern/near-future setting

Do sharpies or markers damage soft rock climbing gear?

Was a star-crossed lover

Many many thanks

Does trying to charm an uncharmable creature cost a spell slot?

How many petaflops does it take to land on the moon? What does Artemis need with an Aitken?

A first "Hangman" game in Python

If I said I had $100 when asked, but I actually had $200, would I be lying by omission?



Python coverage crashing when using unittest.mock


Calling an external command in PythonWhat are metaclasses in Python?Is there a way to run Python on Android?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How can I safely create a nested directory?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have a Python library in which I am setting up some tests. As parts of the tests I am using MagicMock to mock some features like JSON load and files openning and closing. The tests work, everything works as expected.



The issue comes when I try to run the tests with coverage. Since I introduced the new tests that use mock I get coverage crashing.



This is the part where I am implementing the mocking:



def setUp(self):
# Setup the content of the config files for the tests
json.load = MagicMock(side_effect=file_content)

# Opening a file returns the name of the file
def get_mock_context(filename):
mock_context = MagicMock()
mock_context.__enter__.return_value = filename
mock_context.__exit__.return_value = False
return mock_context
builtins.open = MagicMock(side_effect=get_mock_context)


As mentioned, when I run the tests everything seems to be working fine



python -m unittest discover -s tests -p "*Tests.py" 
...........................
----------------------------------------------------------------------
Ran 27 tests in 1.322s

OK


Nonetheless, as soon as I introduce coverage:



coverage run -m unittest discover -s tests -p "*Tests.py"
...........................
----------------------------------------------------------------------
Ran 27 tests in 1.759s

OK
Traceback (most recent call last):
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
self.run_python_module(args[0], args)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
exec(code, main_mod.__dict__)
File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
self.runTests()
File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
sys.exit(main())
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
status = CoverageScript().command_line(argv)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
return self.do_run(options, args)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
self.coverage.save()
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 782, in save
self.data_files.write(self.data, suffix=self.data_suffix)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 680, in write
data.write_file(filename)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 467, in write_file
with open(filename, 'w') as fdata:
File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 951, in __call__
return _mock_self._mock_call(*args, **kwargs)
File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 1017, in _mock_call
result = effect(*args, **kwargs)
TypeError: get_mock_context() takes 1 positional argument but 2 were given


I have no idea what the issue might be. I have tried excluding the lines in the tests files that include mocking with pragma: no cover but that did nothing. I cannot find a way to make this work again. Any ideas or something you think I might have missed?



EDIT:



I just cleaned a bit the code y pasted before. If I run coverage specifying that I want to to use as source only the files in my local directory (to avoid using coverage in python libraries etc) I get the following error. Still not working, but a different one:



Traceback (most recent call last):
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
self.run_python_module(args[0], args)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
exec(code, main_mod.__dict__)
File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
self.runTests()
File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
sys.exit(main())
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
status = CoverageScript().command_line(argv)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
return self.do_run(options, args)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
self.coverage.save()
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 781, in save
self.get_data()
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 834, in get_data
self._post_save_work()
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 864, in _post_save_work
self._find_unexecuted_files(src)
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 913, in _find_unexecuted_files
for file_path, plugin_name in itertools.chain(py_files, plugin_files):
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 910, in <genexpr>
py_files = ((py_file, None) for py_file in find_python_files(src_dir))
File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/files.py", line 416, in find_python_files
del dirnames[:]
TypeError: 'tuple' object does not support item deletion









share|improve this question
































    1















    I have a Python library in which I am setting up some tests. As parts of the tests I am using MagicMock to mock some features like JSON load and files openning and closing. The tests work, everything works as expected.



    The issue comes when I try to run the tests with coverage. Since I introduced the new tests that use mock I get coverage crashing.



    This is the part where I am implementing the mocking:



    def setUp(self):
    # Setup the content of the config files for the tests
    json.load = MagicMock(side_effect=file_content)

    # Opening a file returns the name of the file
    def get_mock_context(filename):
    mock_context = MagicMock()
    mock_context.__enter__.return_value = filename
    mock_context.__exit__.return_value = False
    return mock_context
    builtins.open = MagicMock(side_effect=get_mock_context)


    As mentioned, when I run the tests everything seems to be working fine



    python -m unittest discover -s tests -p "*Tests.py" 
    ...........................
    ----------------------------------------------------------------------
    Ran 27 tests in 1.322s

    OK


    Nonetheless, as soon as I introduce coverage:



    coverage run -m unittest discover -s tests -p "*Tests.py"
    ...........................
    ----------------------------------------------------------------------
    Ran 27 tests in 1.759s

    OK
    Traceback (most recent call last):
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
    self.run_python_module(args[0], args)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
    run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
    exec(code, main_mod.__dict__)
    File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
    main(module=None)
    File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
    self.runTests()
    File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
    sys.exit(main())
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
    status = CoverageScript().command_line(argv)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
    return self.do_run(options, args)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
    self.coverage.save()
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 782, in save
    self.data_files.write(self.data, suffix=self.data_suffix)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 680, in write
    data.write_file(filename)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 467, in write_file
    with open(filename, 'w') as fdata:
    File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 951, in __call__
    return _mock_self._mock_call(*args, **kwargs)
    File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 1017, in _mock_call
    result = effect(*args, **kwargs)
    TypeError: get_mock_context() takes 1 positional argument but 2 were given


    I have no idea what the issue might be. I have tried excluding the lines in the tests files that include mocking with pragma: no cover but that did nothing. I cannot find a way to make this work again. Any ideas or something you think I might have missed?



    EDIT:



    I just cleaned a bit the code y pasted before. If I run coverage specifying that I want to to use as source only the files in my local directory (to avoid using coverage in python libraries etc) I get the following error. Still not working, but a different one:



    Traceback (most recent call last):
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
    self.run_python_module(args[0], args)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
    run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
    exec(code, main_mod.__dict__)
    File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
    main(module=None)
    File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
    self.runTests()
    File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
    sys.exit(main())
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
    status = CoverageScript().command_line(argv)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
    return self.do_run(options, args)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
    self.coverage.save()
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 781, in save
    self.get_data()
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 834, in get_data
    self._post_save_work()
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 864, in _post_save_work
    self._find_unexecuted_files(src)
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 913, in _find_unexecuted_files
    for file_path, plugin_name in itertools.chain(py_files, plugin_files):
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 910, in <genexpr>
    py_files = ((py_file, None) for py_file in find_python_files(src_dir))
    File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/files.py", line 416, in find_python_files
    del dirnames[:]
    TypeError: 'tuple' object does not support item deletion









    share|improve this question




























      1












      1








      1








      I have a Python library in which I am setting up some tests. As parts of the tests I am using MagicMock to mock some features like JSON load and files openning and closing. The tests work, everything works as expected.



      The issue comes when I try to run the tests with coverage. Since I introduced the new tests that use mock I get coverage crashing.



      This is the part where I am implementing the mocking:



      def setUp(self):
      # Setup the content of the config files for the tests
      json.load = MagicMock(side_effect=file_content)

      # Opening a file returns the name of the file
      def get_mock_context(filename):
      mock_context = MagicMock()
      mock_context.__enter__.return_value = filename
      mock_context.__exit__.return_value = False
      return mock_context
      builtins.open = MagicMock(side_effect=get_mock_context)


      As mentioned, when I run the tests everything seems to be working fine



      python -m unittest discover -s tests -p "*Tests.py" 
      ...........................
      ----------------------------------------------------------------------
      Ran 27 tests in 1.322s

      OK


      Nonetheless, as soon as I introduce coverage:



      coverage run -m unittest discover -s tests -p "*Tests.py"
      ...........................
      ----------------------------------------------------------------------
      Ran 27 tests in 1.759s

      OK
      Traceback (most recent call last):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
      self.run_python_module(args[0], args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
      run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
      exec(code, main_mod.__dict__)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
      main(module=None)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
      self.runTests()
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
      sys.exit(main())
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
      status = CoverageScript().command_line(argv)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
      return self.do_run(options, args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
      self.coverage.save()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 782, in save
      self.data_files.write(self.data, suffix=self.data_suffix)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 680, in write
      data.write_file(filename)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 467, in write_file
      with open(filename, 'w') as fdata:
      File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 951, in __call__
      return _mock_self._mock_call(*args, **kwargs)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 1017, in _mock_call
      result = effect(*args, **kwargs)
      TypeError: get_mock_context() takes 1 positional argument but 2 were given


      I have no idea what the issue might be. I have tried excluding the lines in the tests files that include mocking with pragma: no cover but that did nothing. I cannot find a way to make this work again. Any ideas or something you think I might have missed?



      EDIT:



      I just cleaned a bit the code y pasted before. If I run coverage specifying that I want to to use as source only the files in my local directory (to avoid using coverage in python libraries etc) I get the following error. Still not working, but a different one:



      Traceback (most recent call last):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
      self.run_python_module(args[0], args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
      run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
      exec(code, main_mod.__dict__)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
      main(module=None)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
      self.runTests()
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
      sys.exit(main())
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
      status = CoverageScript().command_line(argv)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
      return self.do_run(options, args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
      self.coverage.save()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 781, in save
      self.get_data()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 834, in get_data
      self._post_save_work()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 864, in _post_save_work
      self._find_unexecuted_files(src)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 913, in _find_unexecuted_files
      for file_path, plugin_name in itertools.chain(py_files, plugin_files):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 910, in <genexpr>
      py_files = ((py_file, None) for py_file in find_python_files(src_dir))
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/files.py", line 416, in find_python_files
      del dirnames[:]
      TypeError: 'tuple' object does not support item deletion









      share|improve this question
















      I have a Python library in which I am setting up some tests. As parts of the tests I am using MagicMock to mock some features like JSON load and files openning and closing. The tests work, everything works as expected.



      The issue comes when I try to run the tests with coverage. Since I introduced the new tests that use mock I get coverage crashing.



      This is the part where I am implementing the mocking:



      def setUp(self):
      # Setup the content of the config files for the tests
      json.load = MagicMock(side_effect=file_content)

      # Opening a file returns the name of the file
      def get_mock_context(filename):
      mock_context = MagicMock()
      mock_context.__enter__.return_value = filename
      mock_context.__exit__.return_value = False
      return mock_context
      builtins.open = MagicMock(side_effect=get_mock_context)


      As mentioned, when I run the tests everything seems to be working fine



      python -m unittest discover -s tests -p "*Tests.py" 
      ...........................
      ----------------------------------------------------------------------
      Ran 27 tests in 1.322s

      OK


      Nonetheless, as soon as I introduce coverage:



      coverage run -m unittest discover -s tests -p "*Tests.py"
      ...........................
      ----------------------------------------------------------------------
      Ran 27 tests in 1.759s

      OK
      Traceback (most recent call last):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
      self.run_python_module(args[0], args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
      run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
      exec(code, main_mod.__dict__)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
      main(module=None)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
      self.runTests()
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
      sys.exit(main())
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
      status = CoverageScript().command_line(argv)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
      return self.do_run(options, args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
      self.coverage.save()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 782, in save
      self.data_files.write(self.data, suffix=self.data_suffix)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 680, in write
      data.write_file(filename)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/data.py", line 467, in write_file
      with open(filename, 'w') as fdata:
      File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 951, in __call__
      return _mock_self._mock_call(*args, **kwargs)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/mock.py", line 1017, in _mock_call
      result = effect(*args, **kwargs)
      TypeError: get_mock_context() takes 1 positional argument but 2 were given


      I have no idea what the issue might be. I have tried excluding the lines in the tests files that include mocking with pragma: no cover but that did nothing. I cannot find a way to make this work again. Any ideas or something you think I might have missed?



      EDIT:



      I just cleaned a bit the code y pasted before. If I run coverage specifying that I want to to use as source only the files in my local directory (to avoid using coverage in python libraries etc) I get the following error. Still not working, but a different one:



      Traceback (most recent call last):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 627, in do_run
      self.run_python_module(args[0], args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 122, in run_python_module
      run_python_file(pathname, args, package=packagename, modulename=modulename, path0=path0)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/execfile.py", line 192, in run_python_file
      exec(code, main_mod.__dict__)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/__main__.py", line 18, in <module>
      main(module=None)
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 101, in __init__
      self.runTests()
      File "/anaconda3/envs/c360/lib/python3.7/unittest/main.py", line 273, 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 "/anaconda3/envs/c360/bin/coverage", line 10, in <module>
      sys.exit(main())
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 756, in main
      status = CoverageScript().command_line(argv)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 491, in command_line
      return self.do_run(options, args)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/cmdline.py", line 641, in do_run
      self.coverage.save()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 781, in save
      self.get_data()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 834, in get_data
      self._post_save_work()
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 864, in _post_save_work
      self._find_unexecuted_files(src)
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 913, in _find_unexecuted_files
      for file_path, plugin_name in itertools.chain(py_files, plugin_files):
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/control.py", line 910, in <genexpr>
      py_files = ((py_file, None) for py_file in find_python_files(src_dir))
      File "/anaconda3/envs/c360/lib/python3.7/site-packages/coverage/files.py", line 416, in find_python_files
      del dirnames[:]
      TypeError: 'tuple' object does not support item deletion






      python unit-testing mocking code-coverage






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 20:34







      Juanpe Araque

















      asked Mar 27 at 20:23









      Juanpe AraqueJuanpe Araque

      1271 silver badge10 bronze badges




      1271 silver badge10 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385827%2fpython-coverage-crashing-when-using-unittest-mock%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55385827%2fpython-coverage-crashing-when-using-unittest-mock%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현