aws-samples / aws-device-farm-appium-python-tests-for-android-sample-app

Apache License 2.0
39 stars 16 forks source link

ImportError: No module named 'native_test' #1

Open leon-wu opened 7 years ago

leon-wu commented 7 years ago

while running

$ py.test --collect-only tests/

there is an error saying 'ImportError: No module named 'native_test'', how can i fix the issue?

_________ ERROR collecting tests/base_tests/native_test.py __________
ImportError while importing test module '/Users/lanzhiwu/Depot/awslabs/aws-device-farm-appium-python-tests-for-android-sample-app/venv/tests/base_tests/native_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/base_tests/__init__.py:1: in <module>
    from native_test import NativeTest
E   ImportError: No module named 'native_test'
________ ERROR collecting tests/native/image_gallery_test.py ________
ImportError while importing test module '/Users/lanzhiwu/Depot/awslabs/aws-device-farm-appium-python-tests-for-android-sample-app/venv/tests/native/image_gallery_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/native/image_gallery_test.py:14: in <module>
    from tests.tests.base_tests import NativeTest
E   ImportError: No module named 'tests.tests'
________ ERROR collecting tests/native/video_player_test.py _________
ImportError while importing test module '/Users/lanzhiwu/Depot/awslabs/aws-device-farm-appium-python-tests-for-android-sample-app/venv/tests/native/video_player_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/native/video_player_test.py:14: in <module>
    from tests.tests.base_tests import NativeTest
E   ImportError: No module named 'tests.tests'
!!!!!!!!!!!!!! Interrupted: 9 errors during collection !!!!!!!!!!!!!!
jamesknowsbest commented 6 years ago

I had this problem too. Clear the python cache first then run:

py.test --collect-only tests/

colorfulberry commented 6 years ago

Same problem occured

ptadei commented 4 years ago

You can solve using this link as guide: https://stackoverflow.com/questions/43728431/relative-imports-modulenotfounderror-no-module-named-x

OR

If you prefer, you can adjust the import paths, for example: on "tests/pages/native/init.py" you have:

from alerts_page import AlertsPage
from login_page import LoginPage
from navigation_page import NavigationPage
from nested_views_page import NestedViewsPage
from web_page import WebPage
from tests.pages.base_pages.tab_view_page import TabViewPage
from tests.pages.native.video_player_page import VideoPlayerPage
from tests.pages.native.image_gallery_page import ImageGalleryPage

you can change to:

from tests.pages.alerts_page import AlertsPage
from tests.pages.login_page import LoginPage
from tests.pages.navigation_page import NavigationPage
from tests.pages.nested_views_page import NestedViewsPage
from tests.pages.web_page import WebPage
from tests.pages.base_pages.tab_view_page import TabViewPage
from tests.pages.native.video_player_page import VideoPlayerPage
from tests.pages.native.image_gallery_page import ImageGalleryPage

it works too.

sga-guo-ye commented 4 years ago

Cleared the cache and then I tried the methods above, it does not work for me.

kvishweshwar commented 3 years ago

any updates on this issue please ?

can aws team provide proper samples which will work for newbies and there should not be any prerequisite of expert knowledge of code language of given sample ?

example provided in this blog https://aws.amazon.com/blogs/mobile/test-ios-apps-on-aws-device-farm-using-appium-part-1-prerequisities-environment-set-up-and-test-creation/ is also not working.. the given example require xcode 7 but, current xcode version is 13; which is blocker..

sample example provided in this git bucket https://github.com/aws-samples/aws-device-farm-appium-python-tests-for-android-sample-app/blob/master/README.md is also not working.. it is giving above mentioned error..

So in a nutshell; none of the examples provided above are working for customer. what is use of such examples ?