简体   繁体   English

如何解决未解决的导入错误警告(这似乎是无效的警告)?

[英]How to fix error warning for unresolved import(which seems to be invalid warning)?

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from configuration import config
from org.act.pages.HomePage import HomePageTabs

class VerifyTabs(unittest.TestCase):

    def setUp(self):  
        binary = FirefoxBinary(config.FIREFOX_BINARY_PATH)
        self.driver = webdriver.Firefox(firefox_profile=config.FIREFOX_PROFILE_PATH, firefox_binary=binary)
        self.homepage=HomePageTabs(self.driver)


    def test_home_page_tab(self):
        driver = self.driver
        homepage=self.homepage

        driver.get(config.APP_URL)
        .
        .
        .

    def tearDown(self):
        self.driver.quit()

if __name__ == "__main__":
    unittest.main()

In my PyDev project, I have created one folder as "configuration" and there is config.py file inside it. 在我的PyDev项目中,我创建了一个文件夹作为“ configuration”,其中包含config.py文件。 In my test class I am importing config.py file and reading data as shown in the code above(this is similar to Java properties file). 在测试类中,我将导入config.py文件并读取数据,如上面的代码所示(这类似于Java属性文件)。 My code works properly, but sometimes it shows error warning as Unresolved import:config at 我的代码正常运行,但有时在以下位置显示错误警告,显示为Unresolved import:config

from configuration import config 从配置导入配置

But I observe if I delete the above line and write it once again, sometimes error warning disappear. 但是我观察是否删除了上面的行并再次写了它,有时错误警告消失了。 Any idea why it happens only at this import statement? 知道为什么它仅在此import语句中发生吗?

Can you post a screenshot of your pydev package explorer for that project? 您可以为该项目发布pydev软件包浏览器的屏幕截图吗?

When you run, does it always work? 当您运行时,它始终有效吗?

Usually, I'd suggest you create a package for your own code (say: my_project) and put the things you want inside it to make sure it's not clashing with some other module you have installed on site-packages (ie: if you had some other configuration module in the site-packages). 通常,我建议您为自己的代码创建一个程序包(例如:my_project),然后将所需的内容放入其中,以确保它不会与站点程序包上安装的其他模块冲突(即:如果您有网站数据包中的其他一些configuration模块)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM