{"action":"closed","issue":{"url":"https://api.github.com/repos/pytest-dev/pytest/issues/2421","repository_url":"https://api.github.com/repos/pytest-dev/pytest","labels_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2421/labels{/name}","comments_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2421/comments","events_url":"https://api.github.com/repos/pytest-dev/pytest/issues/2421/events","html_url":"https://github.com/pytest-dev/pytest/issues/2421","id":230134364,"number":2421,"title":"ModuleNotFoundError when using the tests outside application code layout","user":{"login":"MFry","id":579618,"avatar_url":"https://avatars3.githubusercontent.com/u/579618?v=4","gravatar_id":"","url":"https://api.github.com/users/MFry","html_url":"https://github.com/MFry","followers_url":"https://api.github.com/users/MFry/followers","following_url":"https://api.github.com/users/MFry/following{/other_user}","gists_url":"https://api.github.com/users/MFry/gists{/gist_id}","starred_url":"https://api.github.com/users/MFry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MFry/subscriptions","organizations_url":"https://api.github.com/users/MFry/orgs","repos_url":"https://api.github.com/users/MFry/repos","events_url":"https://api.github.com/users/MFry/events{/privacy}","received_events_url":"https://api.github.com/users/MFry/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-05-20T06:32:17Z","updated_at":"2017-07-28T07:44:11Z","closed_at":"2017-07-28T07:44:11Z","body":"- [x] Include a detailed description of the bug or suggestion\r\n       I was following the test layout in [Good Integration Practices](https://docs.pytest.org/en/latest/goodpractices.html) and I couldn't get my tests that were in a similar configuration to run or the simple example I created below.\r\n\r\n- [ ] `pip list` of the virtual environment you are using\r\n\r\n- [x] pytest and operating system versions\r\n       Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-77-generic x86_64)\r\n       platform linux -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0\r\n- [x] Minimal example if possible\r\n ```\r\n\\test_pytest\r\n    mypkg/\r\n        __init__.py\r\n        app.py\r\n    tests/\r\n        test_app.py\r\n```\r\nand the files\r\n``` python\r\n# test_app.py\r\nimport app\r\n\r\n# tried:\r\n# import mypkg.app\r\n# import ..app\r\n# from mypkg import app\r\n```\r\n``` python\r\n# app.py\r\nprint('It Works')\r\ndef test_pass():\r\n    assert True == True\r\n\r\n```\r\nRunning  pytest from the `test_pytest` directory will result in an error  similar to this one.\r\n\r\n`(py36env) ubuntu@ubuntu-xenial:/vagrant/test_pytest$ pytest`\r\n```\r\nImportError while importing test module '/vagrant/test_pytest/test/test_app.py'.\r\nHint: make sure your test modules/packages have valid Python names.\r\ntest/test_app.py:1: in <module>\r\n    import app\r\nE   ModuleNotFoundError: No module named 'app'\r\n```\r\n\r\n\r\nI can add to the `sys` path manually by adding a `__init__.py` to `tests/`\r\n``` python\r\n# test/__init__.py\r\nimport sys\r\nsys.path.append('/vagrant/test_pytest/mypkg')\r\n```\r\nbut that will complicate testing with Travis CI\r\n"}}
{"actor":{"display_login":"RonnyPfannschmidt"}}