def __init__():
with open("config.yaml", 'r') as yamlfile:
cfg = yaml.load(yamlfile)
self.obj = TestMe(cfg.get("general", "user"), cfg.get("general", "passwd")
My YAML File looks like this
general:
user : admin
passwd : admin
I run the test like this
"nosetests test.py --exe --with-xunit --tc-file config.yaml"
I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/nosetests", line 9, in <module>
load_entry_point('nose==1.3.3', 'console_scripts', 'nosetests')()
File "/usr/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
**extra_args)
File "/usr/local/lib/python2.7/unittest/main.py", line 94, in __init__
self.parseArgs(argv)
File "/usr/local/lib/python2.7/site-packages/nose/core.py", line 145, in parseArgs
self.config.configure(argv, doc=self.usage())
File "/usr/local/lib/python2.7/site-packages/nose/config.py", line 346, in configure
self.plugins.configure(options, self)
File "/usr/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 284, in configure
cfg(options, config)
File "/usr/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/usr/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "/usr/local/lib/python2.7/site-packages/testconfig.py", line 129, in configure
options.testconfigencoding)
File "/usr/local/lib/python2.7/site-packages/testconfig.py", line 40, in load_ini
tmpconfig.readfp(f)
File "/usr/local/lib/python2.7/ConfigParser.py", line 324, in readfp
self._read(fp, filename)
File "/usr/local/lib/python2.7/ConfigParser.py", line 512, in _read
raise MissingSectionHeaderError(fpname, lineno, line)
ConfigParser.MissingSectionHeaderError: File contains no section headers.
file: test_config.yaml, line: 1
u'general:\n'
I am confused because on Python CLI i can read the file without any issues.. ?!
The docs suggest that nose-testconfig assumes a INI file on default. You'll need to explicitly tell nose that it's a YAML file:
nosetests test.py --exe --with-xunit --tc-file config.yaml --tc-format yaml
Related
I have always been able to launch spyder without any issues. But today I started running into the following error messages. I don't understand why is it complaining no workingdir? How do I resolve this, as I cannot even launch spyder ?
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\start.py", line 253, in main
mainwindow.main(options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 1956, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\utils.py", line 289, in create_window
main.setup()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 771, in setup
PLUGIN_REGISTRY.register_plugin(self, PluginClass,
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 342, in register_plugin
instance = self._instantiate_spyder5_plugin(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 193, in _instantiate_spyder5_plugin
plugin_instance.initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugins\new_api.py", line 669, in initialize
self.on_initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\plugin.py", line 82, in on_initialize
container.set_history(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 323, in set_history
workdir = self._get_init_workdir()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 183, in _get_init_workdir
workdir = self.get_conf('startup/fixed_directory')
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\config\mixins.py", line 76, in get_conf
return CONF.get(section, option, default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\manager.py", line 499, in get
value = config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 980, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 511, in get
raise cp.NoSectionError(section)
configparser.NoSectionError: No section: 'workingdir'
I am new to airflow. I created a virtual environment and followed the steps in https://airflow.apache.org/docs/apache-airflow/stable/start.html. In the end I gave "airflow standalone" and got "ValueError: Unable to configure handler 'processor'"
(venv) hgovea155#INSML-CPXX7WW AFDocProj % airflow standalone
Unable to load the config, contains a configuration error.
Traceback (most recent call last):
File "/usr/local/opt/python#3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "/usr/local/opt/python#3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 736, in configure_handler
result = factory(**kwargs)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/utils/log/file_processor_handler.py", line 49, in __init__
Path(self._get_log_directory()).mkdir(parents=True, exist_ok=True)
File "/usr/local/opt/python#3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/pathlib.py", line 1273, in mkdir
self._accessor.mkdir(self, mode)
PermissionError: [Errno 13] Permission denied: '/Users/hgovea155/airflow/logs/scheduler/2023-01-02'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/bin/airflow", line 5, in <module>
from airflow.__main__ import main
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/__init__.py", line 46, in <module>
settings.initialize()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/settings.py", line 569, in initialize
LOGGING_CLASS_PATH = configure_logging()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/logging_config.py", line 74, in configure_logging
raise e
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/logging_config.py", line 69, in configure_logging
dictConfig(logging_config)
File "/usr/local/opt/python#3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 800, in dictConfig
dictConfigClass(config).configure()
File "/usr/local/opt/python#3.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/logging/config.py", line 571, in configure
'%r' % name) from e
ValueError: Unable to configure handler 'processor'
I then gave export AIRFLOW_HOME=. after which I gave "airflow standalone" again and I received "airflow.exceptions.AirflowConfigException: Cannot use relative path: sqlite:///./airflow.db to connect to sqlite. Please use absolute path such as sqlite:////tmp/airflow.db."
standalone | Database ready
Traceback (most recent call last):
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/bin/airflow", line 8, in <module>
sys.exit(main())
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/__main__.py", line 39, in main
args.func(args)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/cli_parser.py", line 52, in command
return func(*args, **kwargs)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 48, in entrypoint
StandaloneCommand().run()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 64, in run
self.initialize_database()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 183, in initialize_database
appbuilder = cached_app().appbuilder
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/www/app.py", line 167, in cached_app
app = create_app(config=config, testing=testing)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/www/app.py", line 90, in create_app
f'Cannot use relative path: `{conf.get("database", "SQL_ALCHEMY_CONN")}` to connect to sqlite. '
airflow.exceptions.AirflowConfigException: Cannot use relative path: `sqlite:///./airflow.db` to connect to sqlite. Please use absolute path such as `sqlite:////tmp/airflow.db`.
I then tried the fix provided by #kulasangar
I navigated to user -> airflow and changed the "logs" folder to read write and execute for all users. The "ValueError: Unable to configure handler 'processor'" error didn't occur but I received another error.
(venv) hgovea155#INSML-CPXX7WW AFDocProj % airflow standalone
standalone | Starting Airflow Standalone
standalone | Checking database is initialized
Traceback (most recent call last):
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context
cursor, statement, parameters, context
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: attempt to write a readonly database
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/bin/airflow", line 8, in
sys.exit(main())
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/main.py", line 39, in main
args.func(args)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/cli_parser.py", line 52, in command
return func(*args, **kwargs)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 48, in entrypoint
StandaloneCommand().run()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 64, in run
self.initialize_database()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/cli/commands/standalone_command.py", line 175, in initialize_database
db.initdb()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/utils/session.py", line 75, in wrapper
return func(*args, session=session, **kwargs)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/utils/db.py", line 697, in initdb
_create_db_from_orm(session=session)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/utils/db.py", line 682, in _create_db_from_orm
_create_flask_session_tbl()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/airflow/utils/db.py", line 677, in _create_flask_session_tbl
db.create_all()
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 1094, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/flask_sqlalchemy/init.py", line 1086, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/schema.py", line 4931, in create_all
ddl.SchemaGenerator, self, checkfirst=checkfirst, tables=tables
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 3228, in _run_ddl_visitor
conn._run_ddl_visitor(visitorcallable, element, **kwargs)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2211, in _run_ddl_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
return meth(obj, **kw)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 855, in visit_metadata
_is_metadata_operation=True,
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
return meth(obj, **kw)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 900, in visit_table
include_foreign_key_constraints, # noqa
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/sql/ddl.py", line 81, in _execute_on_connection
self, multiparams, params, execution_options
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1478, in _execute_ddl
compiled,
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1944, in execute_context
e, statement, parameters, cursor, context
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 2125, in handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from=e
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 211, in raise
raise exception
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1901, in _execute_context
cursor, statement, parameters, context
File "/Users/hgovea155/PycharmProjects/AFDocProj/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) attempt to write a readonly database
[SQL:
CREATE TABLE session (
id INTEGER NOT NULL,
session_id VARCHAR(255),
data BLOB,
expiry DATETIME,
PRIMARY KEY (id),
UNIQUE (session_id)
)
]
(Background on this error at: https://sqlalche.me/e/14/e3q8)
Is there a way to fix this? I believe this problem is because of some mistake in the initial setup or configuration. Can a more proper fix be found rather than a temporary one.
It seems like the user doesn't have the privilege to write logs under your airflow distribution folder.
Could you try granting write permission to the folder, so that airflow instance can write logs
sudo chmod -R 777 /home/user/airflow_logs
Please change the logs directory accordingly.
I am trying to run the image with permissions docker run --user 1000:1000 connectors but i got the error:
docker run --user 1000:1000 connectors
* Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
Traceback (most recent call last):
File "/home/connectors/.local/bin/flask", line 8, in <module>
sys.exit(main())
File "/home/connectors/.local/lib/python3.10/site-packages/flask/cli.py", line 988, in main
cli.main()
File "/home/connectors/.local/lib/python3.10/site-packages/flask/cli.py", line 579, in main
return super().main(*args, **kwargs)
File "/home/connectors/.local/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/connectors/.local/lib/python3.10/site-packages/click/core.py", line 1653, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "/home/connectors/.local/lib/python3.10/site-packages/click/core.py", line 1700, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "/home/connectors/.local/lib/python3.10/site-packages/flask/cli.py", line 535, in get_command
return info.load_app().cli.get_command(ctx, name)
File "/home/connectors/.local/lib/python3.10/site-packages/flask/cli.py", line 389, in load_app
app = locate_app(import_name, name)
File "/home/connectors/.local/lib/python3.10/site-packages/flask/cli.py", line 234, in locate_app
__import__(module_name)
File "/app/api/app.py", line 15, in <module>
from api.fields import fields_blueprint
File "/app/api/fields.py", line 13, in <module>
from api.oauth import validate_auth_if_provided
File "/app/api/oauth.py", line 13, in <module>
from base import api_helpers, env
File "/app/base/api_helpers.py", line 11, in <module>
from base import env
File "/app/base/env.py", line 32, in <module>
SECRETS_PATH: str = os.environ["SECRETS_PATH"]
File "/usr/local/lib/python3.10/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'SECRETS_PATH'
Error: '' is not a valid port number.
Trying to set up static assets on a Pyramid app. I used the following call:
config.add_static_view(name='static', path='toolsofknowledge:static')
The file main.css is stored under toolsofknowledge/static/main.css, as expected. The toolsofknowledge package is installed locally with an editable link, using pip3 install -e ..
Requesting http://localhost:8080/static/main.css with curl causes this exception on the server:
amoe#cslp019129 $ PYRAMID_RELOAD_TEMPLATES=1 pserve3 --reload development.ini
Starting monitor for PID 3796.
Starting server in PID 3796.
Serving on http://localhost:8080
Serving on http://localhost:8080
ERROR:waitress:Exception when serving /static/main.css
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pyramid/tweens.py", line 13, in _error_handler
response = request.invoke_exception_view(exc_info)
File "/usr/lib/python3/dist-packages/pyramid/view.py", line 769, in invoke_exception_view
raise HTTPNotFound
pyramid.httpexceptions.HTTPNotFound: The resource could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/waitress/channel.py", line 336, in service
task.service()
File "/usr/lib/python3/dist-packages/waitress/task.py", line 175, in service
self.execute()
File "/usr/lib/python3/dist-packages/waitress/task.py", line 452, in execute
app_iter = self.channel.server.application(env, start_response)
File "/usr/lib/python3/dist-packages/pyramid/router.py", line 270, in __call__
response = self.execution_policy(environ, self)
File "/usr/lib/python3/dist-packages/pyramid/router.py", line 279, in default_execution_policy
return request.invoke_exception_view(reraise=True)
File "/usr/lib/python3/dist-packages/pyramid/view.py", line 768, in invoke_exception_view
reraise_(*exc_info)
File "/usr/lib/python3/dist-packages/pyramid/compat.py", line 179, in reraise
raise value
File "/usr/lib/python3/dist-packages/pyramid/router.py", line 277, in default_execution_policy
return router.invoke_request(request)
File "/usr/lib/python3/dist-packages/pyramid/router.py", line 249, in invoke_request
response = handle_request(request)
File "/usr/lib/python3/dist-packages/pyramid/tweens.py", line 43, in excview_tween
response = _error_handler(request, exc)
File "/usr/lib/python3/dist-packages/pyramid/tweens.py", line 17, in _error_handler
reraise(*exc_info)
File "/usr/lib/python3/dist-packages/pyramid/compat.py", line 179, in reraise
raise value
File "/usr/lib/python3/dist-packages/pyramid/tweens.py", line 41, in excview_tween
response = handler(request)
File "/usr/lib/python3/dist-packages/pyramid/router.py", line 148, in handle_request
registry, request, context, context_iface, view_name
File "/usr/lib/python3/dist-packages/pyramid/view.py", line 657, in _call_view
response = view_callable(context, request)
File "/usr/lib/python3/dist-packages/pyramid/viewderivers.py", line 401, in viewresult_to_response
result = view(context, request)
File "/usr/lib/python3/dist-packages/pyramid/static.py", line 102, in __call__
if resource_isdir(self.package_name, resource_path):
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1138, in resource_isdir
return get_provider(package_or_requirement).resource_isdir(
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 364, in get_provider
return _find_adapter(_provider_factories, loader)(module)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1392, in __init__
self.module_path = os.path.dirname(getattr(module, '__file__', ''))
File "/usr/lib/python3.7/posixpath.py", line 156, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Python 3.7, Pyramid 1.10.2.
Solution: add __init__.py to toolsofknowledge directory.
The problem is quite simple -- the toolsofknowledge package was not a real package, despite being installed, as it was missing an __init__.py. This causes toolsofknowledge.__loader__ to be an instance of NamespaceLoader, when it should be SourceFileLoader. Obviously, pkg_resources cannot resolve resources relative to something that's not a real package. Arguably it should handle this case more smoothly though.
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