question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytest stop working with FileNotFoundError

See original GitHub issue
  • a detailed description of the bug or suggestion
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible

pytest randomly stopped working with the following error:

Traceback (most recent call last):
  File "/anaconda/envs/ggd-testing/bin/pytest", line 11, in <module>
    sys.exit(main())
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 105, in main
    config = _prepareconfig(args, plugins)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 258, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/callers.py", line 203, in _multicall
    gen.send(outcome)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/helpconfig.py", line 90, in pytest_cmdline_parse
    config = outcome.get_result()
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 836, in pytest_cmdline_parse
    self.parse(args)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 1044, in parse
    self._preparse(args, addopts=addopts)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 980, in _preparse
    self._initini(args)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/__init__.py", line 909, in _initini
    config=self,
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/findpaths.py", line 141, in determine_setup
    rootdir, inifile, inicfg = getcfg([ancestor], config=config)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/_pytest/config/findpaths.py", line 43, in getcfg
    iniconfig = py.iniconfig.IniConfig(p)
  File "/anaconda/envs/ggd-testing/lib/python3.6/site-packages/py/_vendored_packages/iniconfig.py", line 52, in __init__
    f = open(self.path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/tox.ini'

I have not needed tox.ini before and I cannot set the path for tox.ini now.

My previous rootdir, according to pytest output was:

============================================================================= test session starts ==============================================================================
platform linux -- Python 3.6.7, pytest-4.5.0, py-1.9.0, pluggy-0.13.1
rootdir: /home/USER/GROUP/ggd/ggd-cli
plugins: socket-0.3.3

pytest is being run in /home/USER/GROUP/ggd/ggd-cli

Uninstalling and reinstalling does not fix the problem

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mikecormiercommented, Jul 11, 2020

Thanks for your help

0reactions
mikecormiercommented, Jul 11, 2020

Thanks for the idea

Read more comments on GitHub >

github_iconTop Results From Across the Web

FileNotFoundError when using python -m pytest vs. pytest
Open the terminal in VS Code; Let the virtual environment activate; Run python -m pip install pytest. That will install pytest into the...
Read more >
Testing with pytest always issues a file not found error #6548
Whenever I run the tests, I always getting this strange error: Detail: Unable to read file (Error: File not found
Read more >
Python Testing with pytest, Second Edition: File not Found ...
Workaround that worked for me was to just manually create the cards_db directory and then a hidden file named name . cards_db.
Read more >
pytest: FileNotFoundError: [Errno 2] only when running ...
i've configured pytest to work in pycharm. i am able to run / debug tests OK. the only issue is when i try...
Read more >
Changelog — pytest documentation
#10060: When running with --pdb , TestCase.tearDown is no longer called for tests when the class has been skipped via unittest.skip or pytest.mark....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found