Skip to content

Error: FileNotFoundError: [Errno 2] No such file or directory #346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paulocoutinhox opened this issue Oct 2, 2019 · 6 comments
Closed

Comments

@paulocoutinhox
Copy link

Im getting the following error and i don't know why:

platform darwin -- Python 3.7.4, pytest-5.2.0, py-1.7.0, pluggy-0.13.0
rootdir: /Users/paulo/Developer/workspaces/python/mytool
plugins: cov-2.7.1
collected 27 items                                                                                                                                                                                         

tests/test_cli.py ...                                                                                                                                                                                [ 11%]
tests/commands/test_base.py .                                                                                                                                                                        [ 14%]
tests/commands/test_generate.py ....                                                                                                                                                                 [ 29%]
tests/models/test_constants.py .                                                                                                                                                                     [ 33%]
tests/models/test_logger.py .........                                                                                                                                                                [ 66%]
tests/models/util/test_file_util.py .......                                                                                                                                                          [ 92%]
tests/models/util/test_generator_util.py ..                                                                                                                                                          [100%]
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 191, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/_pytest/main.py", line 235, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
INTERNALERROR>     return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
INTERNALERROR>     firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pluggy/callers.py", line 203, in _multicall
INTERNALERROR>     gen.send(outcome)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_cov/plugin.py", line 229, in pytest_runtestloop
INTERNALERROR>     self.cov_controller.finish()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/pytest_cov/engine.py", line 171, in finish
INTERNALERROR>     self.cov.stop()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/coverage/control.py", line 675, in load
INTERNALERROR>     self._init()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/coverage/control.py", line 223, in _init
INTERNALERROR>     set_relative_directory()
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/coverage/files.py", line 28, in set_relative_directory
INTERNALERROR>     RELATIVE_DIR = os.path.normcase(abs_file(os.curdir) + os.sep)
INTERNALERROR>   File "/usr/local/lib/python3.7/site-packages/coverage/files.py", line 163, in abs_file
INTERNALERROR>     path = os.path.realpath(path)
INTERNALERROR>   File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 396, in realpath
INTERNALERROR>     return abspath(path)
INTERNALERROR>   File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 383, in abspath
INTERNALERROR>     cwd = os.getcwd()
INTERNALERROR> FileNotFoundError: [Errno 2] No such file or directory

============================================================================================ 27 passed in 3.10s ============================================================================================
make: *** [test-cov] Error 3

Can anyone help me?

Thanks.

@paulocoutinhox
Copy link
Author

My requirements:

testfixtures==6.10.0
pytest==5.2.0
pytest-cov==2.7.1
coverage==4.5.4
pyyaml==5.1.2
docopt==0.6.2
python-slugify==3.0.4
jinja2==2.10.1
colorama==0.4.1

@nedbat
Copy link
Collaborator

nedbat commented Oct 2, 2019

It looks like your current directory has been deleted? Does that make sense?

@nedbat
Copy link
Collaborator

nedbat commented Oct 2, 2019

I think this is a duplicate of #306

@paulocoutinhox
Copy link
Author

Yes, after test this is solved. The following code is a sample for everyone that want:

class TestFileUtil(TestCase):
    @pytest.fixture(scope="class", autouse=True)
    def in_tmpdir(self, tmpdir_factory):
        d = tmpdir_factory.mktemp("d")
        with d.as_cwd():
            yield d

    @tempdir()
    def test_create_dir(self, d):
        os.chdir(d.path)

        dir_name_1 = "new-dir-1"
        dir_name_2 = "new-dir-2"

        create_dir_func(dir_name_1)
        create_dir_func(dir_name_2)

        self.assertTrue(os.path.isdir(dir_name_1))
        self.assertTrue(os.path.isdir(os.path.join(dir_name_1, dir_name_2)))

Thanks a lot.

@nedbat
Copy link
Collaborator

nedbat commented Oct 24, 2019

This is a duplicate of #306.

@nedbat nedbat closed this as completed Oct 24, 2019
@jasma-balasangameshwara

Hi,

I am getting FileNotFoundError: [Errno 2] No such file or directory: 'data/raw/census.csv' error when I run the pytest Github Action. The pytests were successful on my local machine.
https://github.com./jasma-balasangameshwara/ml-heroku-fastapi/runs/4775619528?check_suite_focus=true
Kindly let me know the root cause.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants